1 Reply Latest reply on Jan 13, 2016 12:14 PM by grodma

    Set pdf page number to Indesign page number

    grodma Level 1

      I'm looking for an elegant way, in javascript, to loop through a document and set all placed PDF's page numbers (place PDF Option) to match the Indesign page number that they are placed on. In otherwords, a 20 page pdf placed in a 20 page Indesign document where page 1 of the PDF on page 1 of the Indesign doc, page 2 of the PDF is on page 2 of the Indesign doc, etc.


      I presently use a PDF Multipage Import script, which works great but I'd like be able to achieve multiple impositions, on a single page, without having to keep rerunning the script and calculating the position offset. The idea being that a single layout, say business cards, is layed out 8up on a master page (page one of the PDF, one name per page)> the number of pages in the Indesign doc is set to = the number of pages in the pdf >all pages are selected and the master page items released (resulting in page 1 of the pdf being 8up on every page of the Indesign doc)>the script is run and the pdfs change their page numbers to match the page they are on.


      It seems like a walking through an array is the ticket, but I'm a noob and don't understand how to address the pdfs.

      Any help would be appreciated.

        • 1. Re: Set pdf page number to Indesign page number
          grodma Level 1

          A few years ago I posted this and one day the solution came to me. I thought I'd share.

          The idea is that you put a pdf on the master page of an indesign document.

          Set the number of pages in the document to match (PDf page count = Indesign count)

          Select all the pages in the pages window and "Override All Master Page Items" , thus making an independent copy of page 1 on each page

          Delete the original from the master page (no big deal if you don't, but it will throw an ignoreable error)

          Run the script – it will loop through and replace the pdf with the same pdf but the appropriate (matching) page number.



          The script:


          //  Sets all PDFs  page numbers to correspond to the Indesign page they are on.

          // robin@turnitoff.net


          //myDoc = app.activeDocument;

          myGraphics = app.activeDocument.allGraphics;


            for (idx = 0; myGraphics.length > idx; idx++) {




          //converts string (name) to number




          app.pdfPlacePreferences.pageNumber = myPDFpageNumber;

          var g;

          (g=myGraphics[idx]).place(g.itemLink.filePath, false,);