How to Add and Delete Repeated PDF Pages Using Acrobat Page Templates
Question details
The user wants to configure an interactive PDF form that allows end-users to dynamically add or remove repeated input pages by clicking dedicated buttons.

- Product
- Adobe Acrobat Pro DC
- Device & OS
- not provided
- Scenario
- Creating dynamic and scalable PDF forms with repeatable sections using Acrobat Pro.
- Observed behavior
- Needs instructions on setting up Acrobat page templates and applying JavaScript commands to interactive form buttons for spawning and deleting pages.
Ensure you have Adobe Acrobat Pro DC installed, as standard PDF readers do not support the creation of advanced JavaScript page templates. Finalize the design of your repeatable form page before configuring the template.
Use JavaScript and Hidden Page Templates in Acrobat Pro
Configure a specific document page as a hidden template and attach JavaScript actions to form buttons to control the spawning and deletion of that page.
Acrobat Pro DC allows you to designate a page as a reusable template. By leveraging Adobe's JavaScript API, you can map the 'spawnPageFromTemplate' and 'deletePages' methods to interactive buttons, giving users complete control over adding or removing form sections dynamically.
Open your document in Acrobat Pro. Navigate to 'Organize Pages', select the page you want to make repeatable, and click 'More' > 'Page Templates'. Name your template (e.g., 'RepeatPage'), click 'Add', and check the 'Hidden' icon if you do not want the source template to be visible to the user.
Go to the 'Prepare Form' tool and insert a Button field. Right-click the button, select 'Properties', and navigate to the 'Actions' tab. Select 'Run a JavaScript' from the 'Select Action' dropdown and click 'Add'.
In the JavaScript Editor, type a script to spawn the page. For example: var expTplt = getTemplate('RepeatPage'); expTplt.spawn({nPage: pageNum, bRename: true, bOverlay: false}); Click OK to save the action.
Add a second button for deletion. In its 'Actions' tab, select 'Run a JavaScript' and enter a script such as: if (numPages > 1) { deletePages(pageNum); } Ensure you add logic to prevent deleting the final remaining page of the document.
Save the PDF and switch to Preview mode or open it in Adobe Acrobat Reader. Click the buttons to verify that the pages are successfully added and removed.

Easily Manage PDF Pages and Office Documents with WPS Office
While dynamic JavaScript template spawning is a highly specific feature of Adobe Acrobat Pro, WPS Office provides a powerful, lightweight, and free alternative for your daily document and PDF needs. You can easily insert, extract, delete, and organize PDF pages manually within a familiar interface, alongside robust word processing, spreadsheet, and presentation tools.

Frequently Asked Questions
Why do the Add and Delete buttons fail to work when users open the PDF in Google Chrome?
Built-in PDF viewers in modern web browsers (like Google Chrome, Microsoft Edge, or Safari) lack support for advanced Acrobat JavaScript features, including page template spawning. For the buttons to work, users must download the PDF and open it in a dedicated program like Adobe Acrobat Reader.
Can I hide the original template so users only see it when they click the Add button?
Yes. When you configure the page template in the 'Organize Pages' > 'Page Templates' menu in Acrobat Pro, you can toggle the template's visibility to 'Hidden'. The JavaScript will still be able to successfully spawn copies of this hidden page.
How do I prevent form fields from mirroring data across the newly added pages?
To prevent data duplication, ensure your JavaScript spawn command includes the parameter 'bRename: true' (e.g., expTplt.spawn({nPage: pageNum, bRename: true})). This forces Acrobat to generate unique field names for every spawned copy of the template.




