Working with Images
QXML for image
Image is represented by the <qx-img> node. It contains the following attributes:
|
Attribute |
Value |
Description |
|
|
|
text |
Source of Image, i.e, the path from where the image is to be taken |
|
|
|
text |
Import particular page of a PDF file |
|
|
|
|
Bounding box of PDF file |
|
|
|
Uses the size of the page, not including space for bleeds or registration marks. |
||
|
|
Uses the size of the page plus space for any specified bleeds and space allotted for registration marks. It equals the size of the layout space from the PDF Boxer XT software standpoint. |
||
|
|
Uses the size of the page plus space for bleeds. |
||
|
|
Uses the size of the page after trimming is done. This option does not include registration marks and is unaffected by any bleeds applied to the layout space when the PDF is created. |
||
Import image in picture box
To import an image in a picture box:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>and<qx-img>node. -
Set the 'src' attribute to 'file:///C:/test.jpg'.
Sample JavaScript:
var layout = app.activeLayoutDOM();
var boxes = layout.getElementsByTagName('qx-box');
var images = boxes[0].getElementsByTagName('qx-img');
images[0].setAttribute('src','file:///C:/test.jpg');
Change existing image
To change an existing image:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>and<qx-img>node. -
Change the 'src' attribute to 'file:///C:/new_test.jpg'.
Sample JavaScript:
var layout = app.activeLayoutDOM();
var boxes = layout.getElementsByTagName('qx-box');
var images = boxes[0].getElementsByTagName('qx-img');
images[0].setAttribute('src','file:///C:/new_test.jpg');
Apply Offsets
Offset across
To apply offset across:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxOffsetAcrossstyling property to'0.5in'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxOffsetAcross='0.5in';
Offset down
To apply offset down:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxOffsetDownstyling property to'0.5in'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxOffsetDown='0.5in';
Apply transform
Scale horizontally
To scale horizontally:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxTransformstyling property to'scaleX(0.5)'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxTransform='scaleX(0.5)';
Scale vertically
To apply scale vertically:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxTransformstyling property to'scaleY(0.5)'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxTransform='scaleY(0.5)';
Rotate
To apply rotate:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxTransformstyling property to'rotate(30deg)'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxTransform='rotate(30deg)';
Skew
To apply skew:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxTransformstyling property to'skew(40deg)'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxTransform='skew(40deg)';
Apply color
To apply color to a monochrome image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxColorstyling property to'cyan'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxColor='cyan';
Apply shade
To apply shade to a monochrome image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxShadestyling property to'0.7'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxShade='0.7';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Apply opacity
To apply opacity to a monochrome image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxOpacitystyling property to'0.9'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxOpacity='0.9';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Apply mix blend mode
To apply mix blend mode to an image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxMixBlendModestyling property to'darken'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxMixBlendMode='darken';
Apply background color
To apply background color to a monochrome image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxBackgroundColorstyling property to'magenta'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxBackgroundColor='magenta';
Apply background shade
To apply background shade to a monochrome image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxBackgroundShadestyling property to'0.8'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxBackgroundShade='0.8';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Apply background opacity
To apply background opacity to a monochrome image:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Get the
<qx-img>node. -
Set the
qxBackgroundOpacitystyling property to'0.5'.var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var images = boxes[0].getElementsByTagName('qx-img'); images[0].style.qxBackgroundOpacity='0.5';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Flip image vertically
To apply flip image vertically:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Set the
styling property toqxImgFlipVertical'true'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; boxes.style.qxImgFlipVertical='true';
Flip image horizontally
To flip image horizontally:
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Set the
styling property toqxImgFlipHorizontal'true'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; boxes.style.qxImgFlipHorizontal='true';
Suppress output of image
To suppress output of image are:-
-
Get the DOM of the active layout.
-
Get the
<qx-box>node . -
Set the
styling property toqxImgSuppressOutput'true'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; boxes.style.qxImgSuppressOutput='true';