1

I need to go through an InDesign document a convert all the auto page number special characters to their actual value.

So on each page, find a auto page number symbol and replace it with the value it evaluates to.

I haven't been able to find a script that does that - nor am I an inDesign scripting expert.

Has anyone got a solution for this?

Ben
  • 20,737
  • 12
  • 71
  • 115

1 Answers1

7

Ok, I think I've worked it out.

main();
function main(){
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

    app.findGrepPreferences.findWhat="~N";

    var FindGrep=app.activeDocument.findGrep();
    for(i=0; i<FindGrep.length; i++)
    {
        var item = FindGrep[i];
        var page = item.parentTextFrames[0].parentPage;
        item.contents = page.name;
    }

    alert("done");

}

Struggled to find any valuable documentation from Adobe.

This really helped: http://jongware.mit.edu/idcs5/

As well as this SO question: Get current page number in InDesign CS5 from Javascript

Edit: If your page numbering is in a master, you will need to "override all page master items" (check the pages palette)

Edit 2: This worked on inDesign 5.5 (not sure about 6)

Edit 3: Works also on InDesign CC

Community
  • 1
  • 1
Ben
  • 20,737
  • 12
  • 71
  • 115
  • @GiruBhai It's the current page number. See this page for a reference of all the codes http://help.adobe.com/en_US/indesign/cs/using/WSFB3603CC-8D84-48d8-9F77-F3E0644CB0B6a.html#WSa285fff53dea4f8617383751001ea8cb3f-6f59a – Ben Jun 19 '14 at 11:38