Add PDF Pages with a Button Using Acrobat JavaScript
Question details
Create a fillable PDF form that lets users add pages from predefined layouts by clicking a button.

- Product
- Adobe Acrobat Pro
- Device & OS
- not provided
- Scenario
- A form needs optional pages that users can select and add as needed.
- Observed behavior
- Users should be able to choose a predefined layout and add a copy to the form.
Prepare a PDF containing the main form and one page for each optional layout. Open it in Adobe Acrobat Pro and confirm that the page template and form editing tools are available.
Spawn hidden page templates with an Acrobat form button
Use hidden templates and a JavaScript button to let users choose and add an optional page layout.
This approach uses Acrobat page templates and document JavaScript. Test the completed form in the PDF viewers your recipients will use, because support for interactive features varies.
In Acrobat Pro, open Organize Pages and find Page Templates in the additional page tools. Create a named template for each optional layout, using names such as LayoutA and LayoutB.
In the Page Templates dialog, hide each optional template so its source page is not displayed in the form. Keep the main form pages visible.
Open Prepare a Form, add a button to the main form, and open its Properties. Give it a label such as Add Page.
In Button Properties, open Actions, select Mouse Up and Run a JavaScript, then click Add. Enter: var choice = app.popUpMenu('Layout A', 'Layout B'); var name = choice === 'Layout A' ? 'LayoutA' : choice === 'Layout B' ? 'LayoutB' : null; if (name) { var t = this.getTemplate(name); if (t) t.spawn({nPage: this.numPages, bRename: true, bOverlay: false}); }
Save the PDF, exit form editing, and click Add Page. Select each layout and confirm that a copy appears at the end of the document and that its fields work independently.

Use WPS Office for Everyday PDF and Office Work
WPS Office is a free, lightweight office alternative with a familiar interface and Microsoft Office format compatibility for easier migration. It can help with everyday PDF and document work, but it is not a substitute for Acrobat's page-template JavaScript workflow.

Frequently Asked Questions
Why should I hide the page templates?
Hiding a template keeps its source page out of the visible form until a user adds a copy. Use the Page Templates dialog in Acrobat Pro to hide each optional layout.
How can users choose between different page layouts?
Add a form button in Prepare a Form and attach a Run a JavaScript action. The script can display choices with app.popUpMenu and spawn the corresponding named template.
Will fields on added pages have unique names?
In the template spawn call, use bRename: true to rename fields on each spawned copy. Test repeated additions to confirm that users can fill out the copies independently.
Will the button work in every PDF viewer?
Not necessarily. Page templates and Acrobat JavaScript may not be supported in every viewer. Test the saved form in each viewer your recipients are expected to use.




