PDF Editing Issues

How to Add Buttons to Duplicate and Delete PDF Pages in Acrobat

Nimra MalikNimra Malik Oct 28, 2026 868 views

Question details

The user wants to add interactive buttons to a PDF document that can dynamically duplicate a prefilled master page and delete selected pages.

How to Add Buttons to Duplicate and Delete PDF Pages in Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating an interactive PDF form where users can dynamically generate new pages based on a master template and remove pages they no longer need.
Observed behavior
The user needs the duplicated pages to have unique field names so data isn't mirrored, and requires the deletion function to work within document permissions.
Before you start

Ensure you are using Adobe Acrobat Pro, as standard versions or basic PDF readers do not support the creation of advanced JavaScript functions and Template objects required for this task.

Solution 1Recommended

Use JavaScript Template Objects to Spawn and Delete Pages

Convert your master page into a hidden template and assign JavaScript actions to form buttons to dynamically spawn new pages and delete them.

To allow users to add or remove pages within a PDF dynamically, you must utilize Adobe Acrobat's JavaScript API. By defining a Template object, you can 'spawn' new pages on demand.

Passing the correct parameters to the spawn method ensures the new form fields are uniquely named, preventing the duplicated page from mirroring the data typed into the original master page.

1
Create a Page Template

Open the Page Templates dialog in Acrobat (usually found under Organize Pages or by searching 'Page Templates'). Name your master page and add it as a template. You can choose to hide this template so it acts only as a blueprint.

2
Add the Duplicate Button

Use the Prepare Form tool to insert a Button control. In the button's Properties under the Actions tab, select 'Run a JavaScript' as the action. Enter the code to spawn the template. For example: this.getTemplate("YourTemplateName").spawn({nPage: this.pageNum, bRename: true, bOverlay: false});

3
Add the Delete Button

Create another Button control for deleting the current page. Add a 'Run a JavaScript' action and use the deletePages method. For example: this.deletePages(this.pageNum);

4
Test Document Permissions

Save your PDF and test the buttons. Ensure your document security settings allow 'Document Assembly' and JavaScript execution, otherwise the scripts will be blocked.

Use JavaScript Template Objects to Spawn and Delete Pages
Viewer Compatibility: Template spawning and page deletion scripts rely on Adobe's proprietary JavaScript API. These interactive buttons will function correctly in Acrobat and Adobe Reader, but may fail in mobile PDF viewers, Mac Preview, or web browser PDF plugins.
PDF Management Made Easy

Easily Manage, Duplicate, and Delete PDF Pages with WPS Office

If you need to quickly duplicate, delete, or organize PDF pages without writing complex JavaScript, WPS PDF provides an intuitive, visual page manager to handle your document assembly effortlessly.

  1. 1. Open the PDF: Launch WPS Office and open your PDF document.
  2. 2. Access Page Management: Navigate to the 'Page' tab on the top ribbon menu to view all pages as thumbnails.
  3. 3. Duplicate a Page: Select the page you wish to copy, click 'Extract' to save a copy, or copy and paste the page directly within the thumbnail view.
  4. 4. Delete a Page: Click the trash can icon on the thumbnail or the 'Delete' button on the top ribbon to instantly remove the selected page.
Visually duplicate and delete pages with a simple, user-friendly interface.Highly compatible with Adobe PDF standards, forms, and formatting.Feature-rich, lightweight PDF editor available across Windows, Mac, Linux, and mobile devices.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the duplicated page copy the text from the original master page?

If your spawned page uses the exact same form field names as the master page, the data will mirror across all copies. Ensure you set the 'bRename' parameter to true in your spawn script so Acrobat automatically assigns unique field names to the newly duplicated page.

Can I hide the master page template so it doesn't print?

Yes. When creating the Template object in Acrobat's Page Templates dialog, you can check the 'Hidden' option. The template will remain invisible in the document until a user clicks the duplicate button to spawn a visible, printable copy.

Why do the duplicate and delete buttons fail in browser PDF viewers?

Most web browsers and lightweight third-party PDF readers do not fully support Adobe's advanced JavaScript API for document assembly. For these interactive buttons to work, the recipient must open the PDF in a fully supported application like Adobe Acrobat or Adobe Reader.

Can I prevent users from accidentally deleting the master page?

Yes. You can add conditional logic (an 'if' statement) in your Delete button's JavaScript to check the page number. If the current page matches the master page's page number, the script can simply return without executing the deletePages command.