Skip to main content
Bart_Bossuyt_-_die_Keure
Known Participant
July 2, 2018
Answered

Rename every page to a text field that page

  • July 2, 2018
  • 6 replies
  • 4369 views

Hi all,

is there any way i can rename every page to a text field on the pages.

On every page i have an article-number and i need to export every page to a seperate pdf files (thanks adobe for that last update!) where that number is in the pdf-filename.

I can do that manually but the amount of pages is getting rather big. so is there a way i can automate this within indesign?

any scripts?

thanks

This topic has been closed for replies.
Correct answer Sunil Yadav

Yes, you can do that,

    Try this,

var c = 0; 

var myStyle = "test";

while(c < app.activeDocument.pages.length){

    var found = findMyTextStyle(myStyle, app.activeDocument.pages);

    //If found then do//

    //else you can choose something else to do//

    //you can find character style instead of paragraph style//

    if(found==null){

        found = "1";

        }

    var sec = app.activeDocument.sections.add(app.activeDocument.pages);

    sec.continueNumbering = false; 

    sec.pageNumberStart = parseInt(found);

    c++; 

    } 

function findMyTextStyle(myStyle, myPage){

    var myStyleFound = null;

    app.findTextPreferences=app.changeTextPreferences=NothingEnum.nothing;

    try{

        // You can use paragraph Style Or character style, depending on your need------------------------

        app.findTextPreferences.appliedParagraphStyle = myStyle;

//~         app.findTextPreferences.appliedParagraphStyle = myStyle;

       

        var myFoundStyle = app.activeDocument.findText();

        app.findTextPreferences=app.changeTextPreferences= NothingEnum.nothing;

        app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

        for(i = 0; i <myFoundStyle.length; i++){

            if(myFoundStyle.insertionPoints[0].paragraphs[0].parentTextFrames[0].parentPage.name.toString() == myPage.name.toString()){

                //You can do something here//

                //Or store your page number start here//

                //And return using variable//

                myStyleFound = myFoundStyle.contents.toString();

                }

            }

        }

    catch(e){}

    return myStyleFound;

    }


Updated one.

var c = 0;    var myStyle = "test";

while(c < app.activeDocument.pages.length){

    var found = findMyTextStyle(myStyle, app.activeDocument.pages);

    if(found==null){

        found = "1";

        }

    try{

        var sec = app.activeDocument.sections.add(app.activeDocument.pages);

        }

    catch(e){

        var sec = app.activeDocument.pages.appliedSection;

        }

    sec.continueNumbering = false;

    sec.pageNumberStart = parseInt(found);

    c++;

    }

function findMyTextStyle(myStyle, myPage){

    var myStyleFound = null;

    app.findTextPreferences=app.changeTextPreferences=NothingEnum.nothing;

    try{

        app.findTextPreferences.appliedCharacterStyle = myStyle;

        var myFoundStyle = app.activeDocument.findText();

        app.findTextPreferences=app.changeTextPreferences= NothingEnum.nothing;

        app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

        for(i = 0; i <myFoundStyle.length; i++){

            if(myFoundStyle.insertionPoints[0].paragraphs[0].parentTextFrames[0].parentPage.name.toString() == myPage.name.toString()){

                myStyleFound = myFoundStyle.contents.toString();

                }

            }

        }

    catch(e){}

    return myStyleFound;

    }

6 replies

Participating Frequently
October 18, 2023

Hi all, a few years ago i asked for this script but i cant get it to work anymore? does this has to do anything with the 2023 version of indesign i'm using? Now i need it for a paragraph style called "REF". Every pagenumber has to have the input on that page with the REF style. so if "12345678" is in the paragraph style "REF" then the pagenumber of that page should be "12345678"

 

Community Expert
July 3, 2018

Hi Bart,

it seems we have a solution. Great.

Nevertheless, look into this here:

https://www.marspremedia.com/software/indesign/pdf-export-single-pages

I suggest you contact the author with a feature request.  :-)

Best,
Uwe

FRIdNGE
July 2, 2018

Hmm! …

If I understand well, what you mean is to export each page to pdf naming it with a specific "article-number" placed on each page!

Right?

Best,

Michel, for FRIdNGE

Stephen Marsh
Community Expert
Community Expert
July 2, 2018

That is my take as well Michel, which is why I offered exactly that solution in my post #10.

FRIdNGE
July 2, 2018

Hi Stephen,

Interesting article! … And thanks for the other articles I'll take time to read next WE! 

Personally, I'm more direct and, say, maybe less prosaic! …

Based on Grep, the script exports to pdf each page with a found! Of course, the name of the pdf file will be, for this page:

ID-123456-789.pdf

Best,

Michel [not for-free script]

Bart_Bossuyt_-_die_Keure
Known Participant
July 2, 2018

Is there a way i can use a textstyle to mark the numbers? and then the pagenummer changes according to that specific Textstyle is some way?

i'm just thinking out loud here

Stephen Marsh
Community Expert
Community Expert
July 2, 2018
Sunil Yadav
Legend
July 2, 2018

Could you please explain more exactly what you want to achieve?

It would be best if you add snapshot.

Bart_Bossuyt_-_die_Keure
Known Participant
July 2, 2018

I have to make Cards wich contains a productnumber and a lot of different information on a product.

I want to change the pagenumber  in the "pages"-screen to that article number so that when i export to seperated pdf's i can put the article number in the filename.

*note that these numbers dont follow each other.

Sunil Yadav
Legend
July 2, 2018

If you want to change every page number, you can achieve this using number & section start section option defining each and every page individually.

You can choose each and every page number to fulfill your need.