Skip to main content
Tarpii
Participating Frequently
February 24, 2017
Answered

Insert a PDF into another PDF - every other page

  • February 24, 2017
  • 2 replies
  • 3680 views

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 has been closed for replies.
Correct answer Bernd Alheit

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.

2 replies

Bernd Alheit
Community Expert
February 24, 2017

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.

Tarpii
TarpiiAuthor
Participating Frequently
February 24, 2017

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!

Bernd Alheit
Community Expert
February 24, 2017

What code do you use now?

try67
Community Expert
February 24, 2017

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

Tarpii
TarpiiAuthor
Participating Frequently
February 24, 2017

Thanks - I get this:

#

SyntaxError: syntax error

1:Console:Exec

undefined