Get current page number in InDesign CS5 from Javas

2019-06-20 02:29发布

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

app.activeDocument.currentPage ?

2条回答
放荡不羁爱自由
2楼-- · 2019-06-20 02:31

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).

查看更多
ら.Afraid
3楼-- · 2019-06-20 02:38

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;
查看更多
登录 后发表回答