Get current page number in InDesign CS5 from Javascript
Asked Answered
C

2

8

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

app.activeDocument.currentPage ?
Chole answered 22/9, 2010 at 14:44 Comment(0)
T
10

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

Theressathereto answered 22/9, 2010 at 15:9 Comment(2)
Is there a way to find out page number from a textFrame?Margalo
Is it possible to get the index of the page and not the name ?Rolland
L
0

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;
Labrie answered 8/4, 2017 at 14:17 Comment(1)
Is there a way to find out page number from a textFrame?Margalo

© 2022 - 2024 — McMap. All rights reserved.