I'm working on an InDesign plugin and I would like to know if it is possible to get the origin of my page?
I was thinking about something like this :
var origin = app.activeDocument.pages[0].getOrigin();
Thank you in advance for your help !
EDIT:
I will explain my problem more precisely:
The mission I have to accomplish here is to display shapes using coordinates that I receive through an API call.
There's a problem with this: the user can edit the origin (x, y) on InDesign. If it changes the origin of the board, the shapes no longer end up where they should be placed normally on the page.
Here in red, the shapes are in the right place.
In blue, they are not in the right place because I modified the origin of the board. So I need to recover the origin of the page to be able to calculate the difference between the origin of my board and the origin of my page. This will allow my shapes to always be in the right place.
The value of a documents
zeroPoint
property is an array of two numbers.For example:
yields
[0,0]
for a newly created document, i.e. for a document whose zero point has not been changed from its default position.Example usage:
When creating a new page item it's necessary to calculate the
zeroPoint
values to ensure you are positioning it at the desired location.Example A:
Let's say we want to add a new square shaped text frame on the first page of a document that's always positioned at the top-left corner of the page regardless of the current zero point position.
In which case our code will be akin to the following:
As you can see, in the preceding example, we subtract the
zeroPointX
andzeroPointY
values from the desiredgeometricBounds
values accordingly when defining them for the new text frame.Example B:
Calculating the the
zeroPoint
values when setting thegeometricBounds
can become tedious, particularly when creating multiple page items. It's often simpler and more efficient to:[x,y]
.The following gist demonstrates the aforementioned approach:
As you can see, in this preceding example it produces the same result as "Example A", however we don't do any calculations when setting the
geometricBounds
, instead we simply define our values as desired, i.e.geometricBounds: [0, 0, 50, 50]