Copy link to clipboard
Copied
Hi, I would like to get the number of the first page of a document. Example: page 5-20, where number 5 is the first page of the document. I got the last page through a bookmark that Indesign itself makes available, but the first page I don't know how to do. Can someone help me?
Hello @PUC Goiás,
You can try this...
var curr_origin = app.activeDocument.viewPreferences.rulerOrigin;
app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
// the location and size for the textframe
var y1 = 0;
var x1 = 0;
var y2 = .125;
var x2 = .125;
var tf = app.documents[0].pages[0].name
app.documents[0].pages[0].textFrames.add({
contents: tf,
geometricBounds: [y1, x1, y2, x2]
});
Regards,
Mike
Copy link to clipboard
Copied
Hello @PUC Goiás,
try this....
doc = app.activeDocument;
for (var i=0; i<doc.pages.length; i ++) {
var myFirstPage = app.activeDocument.pages[i].name;
break;
}
alert(myFirstPage)
Regards,
Mike
Copy link to clipboard
Copied
Both solutions work perfectly. However, I would like to be able to print the result on the screen, that is, insert this information in a text box. It will be possible? thanks for helping!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Totally getting you Mike. Infact I was also skeptical about it, I thought if you have written it there must be a reason to it. But then I convinced myself that even break has been used, so seems like something is not right.
You never know when it's a trick question to bowl you over 🙂
-Manan
Copy link to clipboard
Copied
Fantastic, a quick fix. Is there a way to enter the result into a textbox? Thank you very much for the solution.
Copy link to clipboard
Copied
Hello @PUC Goiás,
You can try this...
var curr_origin = app.activeDocument.viewPreferences.rulerOrigin;
app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
// the location and size for the textframe
var y1 = 0;
var x1 = 0;
var y2 = .125;
var x2 = .125;
var tf = app.documents[0].pages[0].name
app.documents[0].pages[0].textFrames.add({
contents: tf,
geometricBounds: [y1, x1, y2, x2]
});
Regards,
Mike