PDF Editing Issues

How to Dynamically Spawn and Remove PDF Template Pages in Acrobat Reader

Camila MilosovichCamila Milosovich Nov 24, 2026 868 views

Question details

Form designers need a way to allow users to dynamically add and remove optional PDF template pages via buttons in both Adobe Acrobat Pro and the free Reader, without permanently deleting the master template.

How to Dynamically Spawn and Remove PDF Template Pages in Acrobat Reader
Product
Adobe Acrobat Pro and Reader
Device & OS
not provided
Scenario
Creating interactive PDF forms where users can click buttons to spawn optional pages from a template and delete them if no longer needed.
Observed behavior
Designers need the correct methodology to handle template pages because Acrobat Reader has restricted permissions that prevent hiding templates dynamically via runtime scripts.
Before you start

Ensure you are using Adobe Acrobat Pro during the design phase to properly set up the form fields, document properties, and initial JavaScript template configurations.

Solution 1Recommended

Use Hidden Master Templates with JavaScript

Set the master template to hidden at design time and use JavaScript commands to spawn and delete new instances of the page.

To maintain compatibility with Adobe Acrobat Reader, you cannot dynamically hide a template page at runtime due to restricted security permissions. The standard practice is to hide the template upfront and only manipulate the spawned instances.

1
Hide the master template at design time

In Adobe Acrobat Pro, open the Page Templates dialog and ensure your master template is set to 'Hidden' before saving the document.

2
Configure the 'Add Page' button

Add a form button for adding pages. In the button's Action properties, add a Run a JavaScript action and use the `template.spawn()` command to duplicate the hidden template.

3
Configure the 'Remove Page' button

Add a form button for removing pages. Use the `this.deletePages()` command in the JavaScript action, ensuring you specifically target the page index of the spawned instance, not the hidden master.

4
Avoid dynamic hiding in Reader

Do not attempt to write field scripts that hide the master template after it has been shown. Always rely on spawning from an initially hidden template to prevent permission errors in Reader.

Use Hidden Master Templates with JavaScript
Initial Page Requirements: If the template page is required when the document is initially opened, spawn an instance upfront before distributing the document to users.

Easily Add and Manage PDF Pages in WPS Office

If you prefer to avoid complex JavaScript coding for page management, WPS Office provides an intuitive, user-friendly interface to manually insert, extract, and delete PDF pages without needing advanced scripting.

  1. 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF file you wish to modify.
  2. 2. Navigate to the Page tab: Click on the 'Page' tab in the top navigation ribbon to access page management tools.
  3. 3. Insert or delete pages: Use the 'Insert' button to add new blank pages or pages from other files, and select the 'Delete' button to remove any unnecessary pages instantly.
Manage PDF pages visually without complex JavaScriptHighly compatible with standard Adobe PDF formats and interactive formsLightweight, fast, and completely free for basic editing tasks
QA img-9

Frequently Asked Questions

Why can't I hide a template page dynamically in Acrobat Reader?

Acrobat Reader enforces strict security permissions that prevent users from changing the hidden status of a master page template via runtime JavaScript. You can only delete spawned pages.

Does the this.deletePages() command delete the master template?

No, as long as you specify the correct page index of the newly spawned instance in your JavaScript. The hidden master template remains safely intact in the background.

Can free Acrobat Reader users run the template.spawn() command?

Yes, free Acrobat Reader users can execute the spawn command to generate new pages, provided the form designer properly configured the master template as 'Hidden' using Acrobat Pro beforehand.