Skip to main content
haagensharks
Participant
March 2, 2026
Question

Javascript for inserting specific PDF file every two pages?

  • March 2, 2026
  • 1 reply
  • 33 views

Hi. I have found a script online that will insert two blank pages after every two pages of a PDF. What I would like to do is insert a specific PDF file that is stored on my computer, instead of new blank pages. Is there a way to do this with Javascript in the Action Wizard? To be clear, I have a PDF file that is two pages. I want to insert these two pages after every two pages of a longer PDF. Thank you in advance!

    1 reply

    try67
    Community Expert
    Community Expert
    March 2, 2026

    You can use the insertPages command to do that. For example (from the Acrobat JS Reference):
     

    // Insert a cover page to the current document.

    this.insertPages ({
    nPage: -1,
    cPath: "/c/temp/myCoverPage.pdf",
    nStart: 0
    });

    Just be aware you need to run your code in reverse, starting from the last page and going backwards, as adding new page numbers changes the total number of the pages in the file in each run.