PDF Editing Issues

Insert a PDF Template Page with Acrobat JavaScript

Bushra ParveenBushra Parveen Nov 19, 2026 869 views

Question details

The user needs a button to insert a PDF template page after page 6 rather than append it to the end.

Insert a PDF Template Page with Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A form button spawns a template named Circuit Breaker.
Observed behavior
The spawned page is appended to the end of the PDF.
Before you start

Open the PDF in Adobe Acrobat and confirm that the template is named exactly “Circuit Breaker” and that the document has at least six pages. Make sure you can edit the button's JavaScript.

Solution 1Recommended

Specify the insertion index in the template spawn method

Use a zero-based page index to insert the Circuit Breaker template as page 7.

1
Open the button action

In Acrobat, open Prepare a Form, select the button, and open its Properties. On the Actions tab, select the Run a JavaScript action and choose Edit.

2
Set the insertion index

In the JavaScript editor, use: var a = this.getTemplate("Circuit Breaker"); a.spawn(6, false, false); this.calculateNow();

3
Save and test

Save the button properties and the PDF, then click the button. Confirm that the new template page appears after page 6.

Specify the insertion index in the template spawn method
Check form-field behavior: The second argument controls field renaming, and the third controls overlay. Use true for the second argument if the spawned form fields need unique names; false can cause fields with matching names to share values. The calculateNow() call is useful when form calculations need to be refreshed.
Free Microsoft Office alternative

Edit PDF pages and Office files with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and support for common Office formats, making it easy to move between documents. Its PDF tools can help with manual page organization, but they do not fix an Acrobat JavaScript template action.

Organize PDF pages manually with WPS PDF tools.Open and edit Microsoft Office formats, including DOCX, XLSX, and PPTX.Use a familiar interface for a smoother transition from Microsoft Office.Access document tools in a lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why does spawn(6) insert the template as page 7?

The spawn method uses a zero-based page index. Index 6 corresponds to the seventh page position, placing the spawned page after the first six pages.

How can I give the spawned form fields unique names?

Set the bRename argument to true, as in a.spawn(6, true, false). This helps prevent spawned fields from sharing values with existing fields that have the same names.

What does the third spawn argument do?

The third argument is bOverlay. Setting it to false inserts the template as a page rather than overlaying it on an existing page.

Does WPS Office fix the Acrobat button script?

No. Edit and test the template button's JavaScript in Acrobat. WPS PDF tools can provide a manual page-organization alternative, but they do not repair the Acrobat action.