Get current page number in InDesign CS5 from Javascript

我是研究僧i 提交于 2019-12-08 19:32:03

问题


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

app.activeDocument.currentPage ?

回答1:


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




回答2:


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;


来源:https://stackoverflow.com/questions/3770411/get-current-page-number-in-indesign-cs5-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!