Skip to main content
Tarpii
Participating Frequently
Feb 24, 2017 10:25 AM UTC
Answered

Insert a PDF into another PDF - every other page

I have a 2000+ page document that I am trying to insert another PDF after every second page. I'm a Javascript novice and I've managed to get this far. Can anyone offer any advise as to what I'm doing wrong?

for (var i=this.numPages-1; i>=0; i--) {     if (i % 2 == 0) { { this.insertPages(i, "FileToInsert.pdf"); }

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
Feb 24, 2017 11:33 AM UTC

for (var i=this.numPages-1; i>=0; i--)     if (i % 2 != 0) this.insertPages(i, "/c/temp/FileToInsert.pdf");


This is correct. In the console select the whole code and press Ctrl-Enter.

10 replies

Bernd Alheit
Community Expert
Community Expert
Feb 24, 2017 11:10 AM UTC

Use something like this:

for (var i=this.numPages-1; i>=0; i--)

     if (i % 2 != 0) this.insertPages(i, "/c/temp/FileToInsert.pdf");

You must adjust the path of the file.

Translate
Tarpii
TarpiiAuthor
Participating Frequently
Feb 24, 2017 11:18 AM UTC

I've tried adusting the file path (and placing it into my temp folder, but I still get this result:

SyntaxError: syntax error

2:Console:Exec

undefined

Thanks for trying!

Translate
Bernd Alheit
Community Expert
Community Expert
Feb 24, 2017 11:26 AM UTC

What code do you use now?

Translate
try67
Community Expert
Community Expert
Feb 24, 2017 11:07 AM UTC

What happens when you run the code? Is there an error message? If so, what does it say?

Translate
Tarpii
TarpiiAuthor
Participating Frequently
Feb 24, 2017 11:09 AM UTC

Thanks - I get this:

#

SyntaxError: syntax error

1:Console:Exec

undefined

Translate