Question

What is the DOM expression to get current page where the cursor is:

app.activeDocument.currentPage ?
Was it helpful?

Solution

You want:

app.activeWindow.activePage.name;

This will give you the actual page number name as a string (i.e. if your pages are numbered in roman then this will give 'v' for the fifth page).

OTHER TIPS

The below would create a Text Block with the current page number. You could also have this be applied to the master page by changing the page location for which the text frame is placed.

myDocument = app.activeDocument;
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
//Set the bounds of the text frame.
//
myTextFrame.geometricBounds = [0, 0, .52, 5.5];
//Enter text in the text frame.
//("\r" is a return character.+
myTextFrame.contents = "P_";
myTextFrame.parentStory.insertionPoints.item(-1).contents = SpecialCharacters.autoPageNumber;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top