Show PDF Content and Spawn Template Pages in Adobe Acrobat
Question details
Create a PDF form that shows or hides content and spawns template pages while retaining shared header values and entered data.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form needs conditional content, repeated headers, and template pages generated according to user input.
- Observed behavior
- The desired result is for spawned pages to repeat the header and display shared form values without losing data entered on the main page.
Open the form in Adobe Acrobat and check that the required page templates exist, the shared header fields have matching names, and JavaScript is enabled. Identify which pages are generated extras and make sure values you need to retain also exist on a page that will not be deleted.
Spawn template pages with shared form field values
Use matching field names and Acrobat JavaScript when spawned pages should repeat the same header or other shared values.
Fields with the same name represent the same form value. Spawning a template without renaming its fields lets shared fields display the value already entered on the main page.
Keep templates hidden when removing generated pages. Do not use the example deletion range if the document has other pages after the first page that must be retained.
In Acrobat, open Prepare a Form and give each shared header field on the main page and template the same name. Use distinct names for information that must differ between pages.
In Acrobat's page templates tools, verify that the template exists and note its exact name. Replace DetailTemplate in the script below with that name.
In Prepare a Form, open the properties of the button that generates pages. Under Actions, choose Run a JavaScript and add: var t = this.getTemplate("DetailTemplate"); if (!t) { app.alert("Template not found."); } else { if (this.numPages > 1) { this.deletePages({nStart: 1, nEnd: this.numPages - 1}); } t.spawn({nPage: this.numPages, bRename: false, bOverlay: false}); }
Enter header values on the main page, click the generate button, and confirm that the spawned page shows them. Run the button again to check that only intended generated pages are replaced.

Show or hide conditional form fields
Use a form control and a JavaScript action when a field should appear only for a particular selection.
Work with PDF Forms and Office Files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. It can help with everyday PDF viewing and editing, but it does not replace Acrobat's template-spawning JavaScript workflow.

Frequently Asked Questions
Why do spawned pages show the same header values?
Fields with matching names share a value. Spawn the template with bRename: false to keep those names, and enter the shared values in the matching fields on the retained main page.
How can each spawned page have different entries?
Give fields that need independent values unique names. If you use bRename: true when spawning, handle shared header values separately because the spawned fields are renamed.
Will deleting generated pages erase entered data?
It can erase values stored only in fields on those pages. Before using deletePages, keep needed values on a retained page and restrict the deletion range to pages that can safely be replaced.
Why doesn't the visibility script hide the text next to a field?
The field's display property controls the form field itself, not static PDF page content. Put conditional information in a form field or use another suitable Acrobat feature for static content.




