• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get first page document Indesign

Community Beginner ,
Dec 16, 2021 Dec 16, 2021

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?

TOPICS
How to , Scripting

Views

338

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Dec 16, 2021 Dec 16, 2021

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

Votes

Translate

Translate
Advisor ,
Dec 16, 2021 Dec 16, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 16, 2021 Dec 16, 2021

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

Hi @Mike Bro,

Why the loop? Won't the following work

alert(app.documents[0].pages[0].name)

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

@Manan Joshi,

 

yes!....it was 5am here before I had any coffee....

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2021 Dec 16, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 16, 2021 Dec 16, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines