PDF Editing Issues

How to Duplicate Selected PDF Pages Using Acrobat JavaScript

Tauseeq MagsiTauseeq Magsi Oct 28, 2026 869 views

Question details

The user wants to duplicate specific pages within a PDF document using Adobe Acrobat's JavaScript capabilities via the Action Wizard.

How to Duplicate Selected PDF Pages Using Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Using the Acrobat Action Wizard to automate the duplication of selected pages across one or multiple PDF documents.
Observed behavior
Requires a custom JavaScript code snippet to loop through the document and insert copies of specific pages based on zero-based page indexing.
Before you start

Always make a backup copy of your original PDF files before running any automated JavaScript actions, as incorrect page index modifications can duplicate pages in the wrong locations or overwrite document structures.

Solution 1Recommended

Use Acrobat JavaScript to Duplicate PDF Pages

Apply a custom JavaScript snippet in Adobe Acrobat's Action Wizard to automatically duplicate pages within the same document.

Adobe Acrobat allows you to use JavaScript to manipulate PDF pages dynamically. When duplicating pages, you use the 'insertPages' method to insert a copy of a page from the current document into a newly specified location.

When modifying page locations, loop backwards through the document pages. This prevents the page index from shifting forward as new pages are inserted, which can cause the script to target the wrong pages.

1
Open Action Wizard

In Adobe Acrobat, go to the 'Tools' menu and select 'Action Wizard'.

2
Create or Edit an Action

Click 'New Action' to create a new sequence, or edit an existing one. From the 'More Tools' section on the left, add the 'Execute JavaScript' tool to your action steps.

3
Enter the JavaScript Code

Click to open the JavaScript editor and enter your duplication script. For example: `for (var p = this.numPages - 1; p >= 2; p--) { this.insertPages(p, this.path, p, p); }`

4
Adjust Page Indexes

Modify the loop parameters (such as `p >= 2`) and the `insertPages` arguments to target the specific pages you want to duplicate. Remember that Acrobat page indexes are zero-based (page 1 is index 0).

5
Run the Action

Save the JavaScript action, then run it on your currently open PDF file or a batch of selected documents.

Use Acrobat JavaScript to Duplicate PDF Pages
Zero-Based Indexing: Acrobat uses zero-based indexing. If you want to duplicate page 3, the index value you need to use in the JavaScript code is 2.
Code-Free PDF Editing

Use WPS Office to Easily Duplicate Pages Without Scripts

Skip the complex JavaScript coding. WPS Office includes a powerful, built-in PDF editor that allows you to easily duplicate, extract, or reorder selected PDF pages visually in just a few clicks.

  1. 1. Open the PDF in WPS Office: Launch WPS Office and open your PDF document using the built-in WPS PDF tool.
  2. 2. Access Page Management: Click on the 'Page' tab in the top navigation ribbon to enter the visual page management view.
  3. 3. Select Target Pages: Hold down the Ctrl key and click the thumbnails of the specific pages you want to duplicate.
  4. 4. Duplicate Pages Visually: Right-click the selected pages and choose 'Copy' (or extract them), then right-click your desired insertion point and select 'Paste'.
Visually select and duplicate PDF pages without writing any complex scripts.Fully compatible with standard PDF files and Microsoft Office formats (Word, Excel, PowerPoint).Comprehensive PDF toolkit for merging, splitting, and organizing document pages.Lightweight application with an intuitive, user-friendly interface.
microsoft office alternative - wps office

Frequently Asked Questions

What does zero-based indexing mean in Acrobat JavaScript?

Zero-based indexing means the first page of the PDF is referenced as page 0, the second page as page 1, and so forth. You must always subtract 1 from the actual physical page number when writing your JavaScript code to ensure you duplicate the correct page.

Can I duplicate multiple different pages at once using Acrobat JS?

Yes. You can use a loop (such as a 'for' loop) in your JavaScript code to iterate through a sequence of selected page indexes, calling the 'insertPages' method for each index.

Why did my Acrobat JavaScript insert the duplicated pages in the wrong order?

When duplicating multiple pages in a sequence, inserting a new page changes the overall page count and shifts subsequent indexes. It is strongly recommended to loop backwards (from the last page to the first) to prevent this index shifting.

Is there a way to duplicate a PDF page without using JavaScript?

Yes. Most standard PDF editors, including WPS PDF and Adobe Acrobat, allow you to duplicate pages manually. Simply open the Page Thumbnails panel, hold the Ctrl (or Option) key, and drag the page thumbnail to a new position to create a duplicate.