Skip to main content
Participating Frequently
March 22, 2023
Answered

Script to add a page number marker

  • March 22, 2023
  • 2 replies
  • 650 views

Hi all,

I'm trying to add folios to currently unnumbered pages using a pretty simple script like:

app.activeDocument.masterSpreads.item("A-Parent").textFrames.add({
    geometricBounds: ["62", "40", "63", "47"],
    contents: "?",
    itemLayer: "Layer 1",
    parentStory: {appliedParagraphStyle: ""}
})

This creates the box just fine, but I have no idea what to use for the "contents: "?" to insert a current page number marker. I'm not even sure how to look this up. Is it even possible?

 

Thanks for any help!

-Don

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

 

aTextFrame.contents = SpecialCharacters.autoPageNumber

 

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#SpecialCharacters.html

 

2 replies

Community Expert
March 22, 2023

Hi @dona56558947 ,

see a list of special character enumerators at the InDesign DOM documentation compiled by Gregor Fellenz:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#SpecialCharacters.html

 

So this is working:

contents : SpecialCharacters.AUTO_PAGE_NUMBER ,

 

Hm. What do you like to do with:

 parentStory: { appliedParagraphStyle : "" }

If you want to apply the "no paragraph style" style do this:

 parentStory: { appliedParagraphStyle : app.documents[0].paragraphStyles[0] }

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Participating Frequently
March 22, 2023

I was still working on the styling part. Since there are no folios in these docs currently, there is no paragraph style to apply. I've now added another step to first create a "Folio" paragraph style and properly style these new folios. 

Thanks!

Robert at ID-Tasker
Robert at ID-TaskerCorrect answer
Legend
March 22, 2023

 

aTextFrame.contents = SpecialCharacters.autoPageNumber

 

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#SpecialCharacters.html

 

Participating Frequently
March 22, 2023

Yes! And now that I know what to look for, I know how to find them in the API. Thank you!