How can I handle both 'pages[0]' and 'parentPage'?
Scenario 1: I need to retrieve data for the current page, so I use ‘var p = item.parentPage; ‘
For example: The number of columns on the current page is ‘marginPreferences.columnCount; ‘
Scenario 2: I need to move objects within the current page, but I can only use ‘d.Page[0] ‘.
Because the following code(var pb=p.bounds) throws an error: ”null is not an object”.
—I suspect the object is considered out of bounds.
What should I do? Using two sets of code is too complicated.
var d = app.activeDocument;
//var p=d.page[0];
var p = item.parentPage;
// Page bounds
var pb = p.bounds;
.. ....
//If the object is below BleedBottom, move it into the layout
if (s.geometricBounds[0] > ph) {
var dn = ph - (Number(s.geometricBounds[0]) - ph);
s.move([0, dn - rh]);
}



