[JS IDCS5] geometricBounds from XML to inline Frames
The following script is working on InDesign Desktop. It's reading the imported XML to apply the attributes values to the inline graphics as scale, geometricBounds and offset:
// #include "glue code.jsx"
main(myDocument);
function main(){
var myRuleSet = new Array (
new findObjAttribute("//image")
);
with(myDocument){
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
}
function findObjAttribute(XPATH){
this.name = "findObjAttribute";
this.xpath = XPATH;
this.apply = function(myElement, myRuleProcessor)
{
var myHeigth=myElement.xmlAttributes.itemByName("height").value;
var myWidth=myElement.xmlAttributes.itemByName("width").value;
var myScale=parseInt(myElement.xmlAttributes.itemByName("scale").value);
var myXoffset=myElement.xmlAttributes.itemByName("xoffset").value;
var myYoffset=myElement.xmlAttributes.itemByName("yoffset").value;
with(myHeigth, myWidth, myScale, myYoffset, myXoffset){
var myRectangle = myElement.xmlContent.parent;
try {
myRectangle.graphics[0].horizontalScale = myScale;
myRectangle.graphics[0].verticalScale = myScale;
myRectangle.graphics[0].move(undefined, [myYoffset, myXoffset]);
myRectangle.geometricBounds = [0, 0, myHeigth, myWidth];
} catch(e){};
}
return true;
}
}
}
When running it on InDesign Server, the geometricBouns only applies to the first graphic in the document. The scales and the offsets are applied to all the graphics.
Here is an example of the XML:
<Root>
<Paragraph>
<image href="image1.jpg" scale="110" xoffset="-10mm" yoffset="10mm" width="87mm" height="60mm"></image>
</Paragraph>
<Paragraph>
<image href="image2.jpg" scale="90" xoffset="20mm" yoffset="0mm" width="87mm" height="50mm"></image>
</Paragraph>
<Paragraph>
<image href="image3.jpg" scale="100" xoffset="-15mm" yoffset="5mm" width="87mm" height="80mm"></image>
</Paragraph>
</Root>
Why are the geometricBounds values only applying to the first graphic with InDesign Server?
Regards, Sjoerd