Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Insert multiple PDF pages in existing pages (script

Community Beginner ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Hello,

I am using the native InDesign script PlaceMultipagePDF.jsx to ... place multipage PDF. All good.

But I would like to place that multipage PDF in the existing pages of my InDesign document and not in new added pages.

I thought it would be a simple edit to the script... and I am sure it is simple, but apparently not simple for me. Anyone could help?

I looked that thought it would be as simple as replacing the following section:

 

if(myCounter > 1){
	myPage = myDocument.pages.add(LocationOptions.after, myPage);
}
app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];

 

with the following:

 

if(myCounter > 1){
	myPage = myPage + 1;
}
app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];

 

But while myPage returns 2 in the original, with my edit it return undefined. 

It turns out that getting the next existing page is harder than my almost-non-existing scripting abilities allow.

 

Could anyone help? Thanks

N

 
 
 
TOPICS
Scripting

Views

97

Likes

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
Advocate ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Use the  MultiPageImporter script from Scott Zanelli instead.
You will find it at Creative Pro here:

https://creativepro.com/zanelli-releases-multipageimporter-for-importing-both-pdf-and-indd-files/

Likes

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
Community Beginner ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

Thanks @Jean-Claude Tremblay (and Scott Zanelli)

That's really useful and I really like that it puts the insert file in a new layer.

 

Just out of curiosity any ideas why my edit to the original script does not work? Anyone?

Thanks, N

Likes

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
Explorer ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

LATEST

Hi, nsgma:

 

At first sight, "myPage" seems to be an object that describes a page in a document, not only the page number.

You "add" a "page" in your "document" so you obtain a new "page" object.

 

I don't know how you get a "2" with the original code, but could be missunderstood you with the page number itself.

 

Your code then try to sum a page and a number, and the result is "undefined"

 

About adding PDFs pages in the middle of a document, this is how I do it: first, I add the needed blank pages, then I run MultiPageImporter and fill "Start at" with the appropiate page number.

 

I hope it has been helpfull

Likes

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