PDF Editing Issues

Add PDF Pages with a Button Using Acrobat JavaScript

Kushani NimanthikaKushani Nimanthika Nov 19, 2026 868 views

Question details

Create a fillable PDF form that lets users add pages from predefined layouts by clicking a button.

Add PDF Pages with a Button Using Acrobat JavaScript
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.
Before you start

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.

Solution 1Recommended

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.

1
Create page templates

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.

2
Hide the template pages

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.

3
Add a form button

Open Prepare a Form, add a button to the main form, and open its Properties. Give it a label such as Add Page.

4
Add the button script

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}); }

5
Test each layout

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.

Spawn hidden page templates with an Acrobat form button
Printing and viewer support: A custom Print button may be useful for some workflows, but it is not always required. Test printing and template spawning in each intended viewer, including Reader if applicable.
Free Microsoft Office alternative

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.

Open and work with PDFs alongside office documentsCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight suite for everyday document tasks
QA img-9

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.