PDF Editing Issues

How to Duplicate a PDF Page Using Acrobat JavaScript

Steve KSteve K Oct 28, 2026 869 views

Question details

The user wants to automatically duplicate a page across multiple PDF files using Acrobat JavaScript in a custom action.

How to Duplicate a PDF Page Using Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Setting up a document-level workflow or custom Action Wizard batch process to duplicate a specific page within single-page PDF files.
Observed behavior
The goal is to automatically execute a script that inserts an identical copy of the current page directly after the last page, eliminating manual copy-pasting.
Before you start

Always test your JavaScript action on a small batch of duplicate documents before applying it to your main files to ensure the script targets the correct page index.

Solution 1Recommended

Use the insertPages Method in Acrobat Action Wizard

Apply a specific JavaScript snippet using Acrobat's Action Wizard to instantly append a duplicate of the current page to the end of the document.

The `insertPages` method is a powerful built-in function in Adobe Acrobat's JavaScript API. It allows you to insert pages from a specified document into the current one. By referencing the current document's own file path (`this.path`), you can effectively instruct Acrobat to duplicate its own pages.

1
Open the Action Wizard

Launch Adobe Acrobat Pro and navigate to Tools > Action Wizard.

2
Create a New Action

Click 'New Action'. In the left pane under 'Choose tools to add', expand the 'More Tools' section, select 'Execute JavaScript', and click the '+' icon to add it to your action steps on the right.

3
Input the JavaScript Code

Uncheck the 'Prompt user' box next to the newly added step, then click 'Specify Settings'. In the JavaScript editor window, enter the following code: this.insertPages(this.numPages - 1, this.path, 0, 0); and click OK.

4
Run the Batch Process

Save the action with a recognizable name. Add the target PDF files or folders to the action's file list, and click 'Start' to automatically duplicate the pages across all selected documents.

Use the insertPages Method in Acrobat Action Wizard
Understanding the Script Parameters: In the snippet, 'this.numPages - 1' dictates that the new page will be inserted at the end of the document. The '0, 0' indicates that the script is copying the first page (index 0) through the first page (index 0). If you are working with multi-page PDFs and want to duplicate a different page, adjust these index numbers accordingly.
Easy PDF Page Duplication

Duplicate PDF Pages Visually with WPS Office

If you prefer to bypass complex JavaScript programming and batch processing scripts, WPS Office provides an intuitive, visual method to duplicate PDF pages in seconds. It allows you to organize and edit standard Adobe PDF files effortlessly.

  1. 1. Open your PDF Document: Launch WPS Office and open the PDF file you wish to modify.
  2. 2. Access Page Management: Click on the 'Page' tab located in the top navigation ribbon to switch to the thumbnail management view.
  3. 3. Select the Target Page: Click on the thumbnail of the page you want to duplicate to select it.
  4. 4. Duplicate via Drag and Drop: Hold down the 'Ctrl' key on your keyboard, then click and drag the selected thumbnail to the desired position in the document. Release the mouse button to instantly create an exact duplicate.
  5. 5. Save the Document: Click the Save icon or press Ctrl+S to save the changes to your newly expanded PDF file.
No coding or JavaScript knowledge requiredFully compatible with standard Adobe PDF formatsLightweight, fast-loading, and visually intuitive page managementFree built-in tools for merging, splitting, and rearranging PDF pages
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't the Acrobat JavaScript work on a multi-page PDF?

The specific script provided (`this.insertPages(this.numPages - 1, this.path, 0, 0);`) hardcodes the start and end page index as 0, which corresponds to the first page. To copy a different page in a multi-page PDF, you must change the last two zeros to match the zero-based index of the page you wish to duplicate.

Where can I test Acrobat JavaScript before running a batch action?

You can test individual JavaScript snippets by opening a single PDF, navigating to Tools > JavaScript, and opening the JavaScript Debugger console (Ctrl+J on Windows). Type your script, highlight it, and press Ctrl+Enter to execute it on the current document.

Does duplicating a page with JavaScript significantly increase the PDF file size?

Adding a new page will increase the file size slightly. However, Acrobat and standard PDF editors generally optimize duplicates by referencing the original page's structural resources (like embedded images and fonts) instead of duplicating the heavy underlying data.

Can I use JavaScript to duplicate multiple different pages at once?

Yes. The `insertPages` method can specify a range of pages to copy. By modifying the third and fourth parameters of `this.insertPages(nPage, cPath, nStart, nEnd)`, you can copy a sequence of pages (e.g., from index 1 to index 3) and insert them at your target destination.