Hide Spawned Template Fields and Navigate to a New Page in Adobe Acrobat
Question details
Keep fields hidden on a newly spawned PDF template page and navigate to that page.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form uses Acrobat JavaScript to create a page from a template.
- Observed behavior
- The user wants the spawned fields hidden and the new page displayed after it is created.
Confirm the PDF contains a named page template and that you can edit its button actions or document JavaScript in Acrobat. Identify any fields that should remain visible, because hiding every field on the new page will prevent users from entering data in them.
Hide the Spawned Fields and Open the New Acrobat Page
Use this approach when a template is appended to the PDF and its fields should be hidden immediately.
The example appends one page, hides fields associated with that page, and then displays it. Replace MyTemplate with the actual template name. Acrobat page numbers are zero-based.
The example hides all fields on the new page. If only certain fields should be hidden, check their generated names before setting display.hidden.
In Acrobat, open All tools > Prepare a form, select the button that creates the page, and open its Properties. On the Actions tab, edit the Run a JavaScript action.
Use a script like this, replacing MyTemplate with your template name: var t = this.getTemplate('MyTemplate'); if (t) { var newPage = this.numPages; t.spawn({nPage: newPage, bRename: true, bOverlay: false}); for (var i = 0; i < this.numFields; i++) { var f = this.getField(this.getNthFieldName(i)); if (!f) continue; var p = f.page; var onNewPage = (p === newPage); if (p && typeof p !== 'number') { for (var j = 0; j < p.length; j++) { if (p[j] === newPage) onNewPage = true; } } if (onNewPage) f.display = display.hidden; } this.pageNum = newPage; }
Close the script editor and form-editing mode, then click the button. Check that the appended page opens and the intended fields are hidden.

Work With PDF Documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for everyday document and PDF work. Its Microsoft Office format compatibility helps you move existing files into a single workspace. Use Adobe Acrobat for the template-spawning JavaScript described above.

Frequently Asked Questions
How do I navigate to the newly spawned page?
Set the document's this.pageNum property to the new page's zero-based index. When appending one page, save this.numPages before spawning and use that saved value afterward.
Why doesn't setFocus() work on my spawned field?
The field may be hidden, unable to receive focus, or referenced by the wrong name. Inspect the spawned field names using getNthFieldName(), and call setFocus() only on the actual visible field.
How can I hide only some fields on the new page?
After spawning, inspect the generated names with getNthFieldName() and use getField() to select the intended fields. Set each selected field's display property to display.hidden.
Why are the spawned field names different from the template names?
Spawning with bRename set to true generates distinct field names. Use the names present in the document after spawning rather than assuming the original template field names will still work.




