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

Set pdf page number to Indesign page number

New Here ,
Oct 09, 2009 Oct 09, 2009

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

1.4K

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
New Here ,
Jan 13, 2016 Jan 13, 2016

Copy link to clipboard

Copied

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++) {

   if(myGraphics[idx].constructor.name!="PDF"){continue}

myPageNum=myGraphics[idx].parentPage.name;

//converts string (name) to number

myPDFpageNumber=Number(myPageNum);

app.pdfPlacePreferences.pageNumber = myPDFpageNumber;

var g;

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

  }

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
New Here ,
Apr 21, 2023 Apr 21, 2023

Copy link to clipboard

Copied

LATEST

YOU SAVED MY DAY!

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