PDF Editing Issues

Spawn a Hidden PDF Template Based on Two Form Conditions in Adobe Acrobat

Steven ParkerSteven Parker Nov 24, 2026 869 views

Question details

Spawn a hidden PDF page template only when a checkbox is selected and a text field contains an accepted value.

Spawn a Hidden PDF Template Based on Two Form Conditions in Adobe Acrobat
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
A multipage PDF form needs to select and spawn a page template according to two form-field conditions.
Observed behavior
The form should check both conditions before running the template-spawning script.
Before you start

In Acrobat Pro, identify the exact checkbox and text-field names and create a named hidden page template. Decide which text values should trigger each template and test the form in a PDF viewer that supports Acrobat JavaScript.

Solution 1Recommended

Validate the Text Field and Spawn the Matching PDF Template

Use a custom validation script when the text field is completed after the checkbox is selected.

The script checks that the checkbox is not Off and that the entered text matches one of the accepted values. It uses event.value for the text being validated.

This example spawns one template for the listed values. If other values require a different template, add a separate condition and use that template's name.

1
Open the text-field properties

Open the PDF in Acrobat Pro, choose Prepare a Form, then right-click the relevant text field and select Properties.

2
Add the validation script

On the Validate tab, select Run custom validation script and click Edit. Enter: var checkbox = this.getField("CHECKBOX"); var value = String(event.value).replace(/^\s+|\s+$/g, "").toUpperCase(); if (checkbox && checkbox.value !== "Off" && ["BC", "AB", "SK", "MB", "ON"].indexOf(value) !== -1) { var template = this.getTemplate("TemplateName"); if (template) { template.spawn({nPage: this.numPages, bRename: true, bOverlay: false}); } }

3
Replace names and values

In the script editor, replace CHECKBOX with the exact checkbox field name and TemplateName with the hidden template name. Edit the array to match the accepted text values, then confirm the script and close Properties.

4
Test both conditions

Preview the form, select the checkbox, enter an accepted value, and leave the text field to commit it. Repeat with an unchecked box and an unlisted value to confirm that neither case spawns a page.

Validate the Text Field and Spawn the Matching PDF Template
Avoid repeated pages: Validation can run again when the text field is edited, so the example may spawn another page on each matching commit. Add logic to track or remove previously spawned pages if duplicates are unwanted. If the checkbox is changed after the text field is committed, a separate checkbox script is needed to reevaluate the conditions.
Free Microsoft Office alternative

Use WPS Office for Everyday PDF and Office Document Work

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. Its format compatibility makes it easy to move existing documents into WPS. For conditional Acrobat JavaScript template spawning, continue to use Acrobat and a compatible PDF viewer.

Open and work with PDF documents alongside other office filesCompatible with Microsoft Word, Excel, and PowerPoint formats such as DOCX, XLSX, and PPTXFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight suite for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why should I use an array for the accepted text values?

An array lets the script test whether event.value matches any listed value using indexOf. An expression such as value == "BC" || "AB" does not compare value with each string and can evaluate as true unexpectedly.

What does the checkbox value Off mean?

In an Acrobat checkbox field, Off represents the unchecked state. The script checks checkbox.value !== "Off" so that a checked export value can satisfy the condition.

Why does changing the checkbox not spawn a page?

The example runs from the text field's Validate tab when that field is committed. If users may select the checkbox afterward, add a separate checkbox script that reevaluates both conditions.

Can the script spawn a different template for another text value?

Yes. Add another condition for the relevant value or group of values, then call this.getTemplate with the corresponding template name before invoking spawn.

Will this script work in every PDF viewer?

No. The viewer must support the necessary Acrobat JavaScript and template operations. Test the completed form in the intended viewer; Reader usage may also depend on document permissions and enabled features.