nPage is 0-based, while numPages returns the actual number of pages in the
If you want to insert doc2 at the end of the files, use nPage:
Now, the script looks like this:
// Create a new PDF document:
var newDoc = app.newDoc();
// Insert doc1.pdf:
nPage : -1,
cPath : "/d/Cover.pdf",
// Insert doc2.pdf:
nPage : newDoc.numPages-1,
cPath : "/d/Book.pdf",
// Save the new document:
// Close the new document without notifying the user:
The merging works. But there is one empty page between Cover.pdf and Book.pdf in myNewDoc.pdf.
Do you have an idea, why?
1 person found this helpful
That's the single, empty page that is created when you execute newDoc(). A
file must have at least one page.
You can delete it using deletePages. It's location will be the size of doc1
Thank you try67,
for your help. Now it works perfect.