Insert a PDF Template Page with Acrobat JavaScript
Question details
The user needs a button to insert a PDF template page after page 6 rather than append it to the end.

- 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.
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.
Specify the insertion index in the template spawn method
Use a zero-based page index to insert the Circuit Breaker template as page 7.
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.
In the JavaScript editor, use: var a = this.getTemplate("Circuit Breaker"); a.spawn(6, false, false); this.calculateNow();
Save the button properties and the PDF, then click the button. Confirm that the new template page appears after page 6.

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.

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.




