Copy link to clipboard
Copied
Hello friends.
I have a problem with setting geometricbounds of an image in javascript. I submit x, y, width, height and scale X and scale Y percentage. All my params are applied except the X and the Y. I applied these params this way :
for(var j=0;j<page_item.allPageItems.length;j++)
{
var sub_page_item = page_item.allPageItems[i];
if(sub_page_item instanceof Image)
{
var itm = sub_page_item;
var gb = [x, y, width, height];
itm.geometricBounds = gb;
itm.horizontalScale = zoomX;
itm.verticalScale = zoomY;
}
}
Did someone has this kind of problem in the past ? Does someone have a solution ? Thanks for your help.
The parameters for geometricBounds are not:
[ x, y, width, height ]
They are:
y for upper left corner ,
x for upper left corner ,
y for lower right corner,
x for lower right corner
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
The parameters for geometricBounds are not:
[ x, y, width, height ]
They are:
y for upper left corner ,
x for upper left corner ,
y for lower right corner,
x for lower right corner
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
thanks. I 'm gonna try that. We didn't understand the geometric bounds logical. So, if we set the 4 corners, we don't need to set height and with?
Copy link to clipboard
Copied
You could set the width and height to variables and use them in the bounds. Some thing like this sets the selection to 3 x 2 ruler units:
var s = app.documents[0].selection[0];
var y = 1
var x = 1
var h = 2
var w = 3
s.geometricBounds = [y, x, y+h, x+w]
alert("Width: " + getWidthHeight(s)[0] + " Height: " + getWidthHeight(s)[1])
/**
* Get a page item’s width and height
* the page item
* an array [width, height]
*
*/
function getWidthHeight(pi){
var wh = []
var gb = pi.geometricBounds
wh[0] = gb[3]-gb[1];
wh[1] = gb[2]-gb[0]
return wh
}
Copy link to clipboard
Copied
You have two points that are described by two pairs of y and x values.
Geometric bounds always form a rectangular area where the edges of the rectangle are always parallel to the rulers in a layout window. That's all.
Regards,
Uwe Laubender
( ACP )