I am creating an InDesign plugin where one of the features is to draw shapes on a given page.
I get a drawing from the backend with the page number on which it should be drawn.
For this, I do :
app.activeDocument.pages[index]
to get the page I want.
Unfortunately, I realized that this technique only works when the pages are not facing each other like this :
When the pages are facing each other like this :
, the shapes on page 3 will be drawn on page 2 instead of on page 3.
Here, the drawings are on the right page :
But here, the rectangle isn't on the right page :
I also tried to draw the shape in a raw way by doing app.activeDocument.spreads[indexSpread].pages[1]
, which should logically write the note on the 2nd page of the board in question except that it is always drawn on the 1st page of the board.
Here is my code to draw the rectangle :
var doc = app.activeDocument;
var page = doc.pages[pageIndex-1];
var myRectangle = page.rectangles.add();
To address pages inside a spread use the page origin coordinates: