Renumber PDF Form Pages After Deleting a Spawned Page in Adobe Acrobat
Question details
Recalculate page-number fields after deleting a spawned page from a PDF form.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A PDF form uses spawned pages and calculation scripts to display page numbers.
- Observed behavior
- After a spawned page is deleted, its page-number fields need recalculation, but a button on the deleted page cannot reliably run subsequent code.
Open the form in Adobe Acrobat and confirm that its page-number fields have calculation scripts. Make sure the control that runs the deletion is on a page that will remain in the document.
Recalculate the form after deleting the last spawned page
Use a button on a retained page to delete the last spawned page and immediately recalculate the remaining page-number fields.
Deleting only the last spawned page helps avoid duplicate field names when another page is spawned. The deletion and recalculation should run from a control that is not being removed.
In Adobe Acrobat, open the PDF and select Prepare a form. Choose or add a button on a page that will remain after the deletion.
Open the button's Properties, select Actions, and add a Run a JavaScript action. In the JavaScript editor, enter: this.deletePages({nStart: this.numPages - 1}); this.calculateNow();
Save the form, leave the form editor, and click the button. Check that the last page was a spawned page and that the remaining page-number fields display the expected numbers.

Work with PDF forms and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Office files. Its format compatibility makes moving everyday documents easier, although it does not fix Acrobat-specific form scripts.

Frequently Asked Questions
Why should the delete button be on a different page?
A button on the page being deleted may not reliably continue executing after that page is removed. Place the button on a retained page so it can call this.calculateNow() after deletion.
What does this.calculateNow() do?
In an Acrobat JavaScript action, this.calculateNow() triggers form-field calculations. It updates page-number fields only if their calculation scripts are configured to produce the desired numbers.
Can I delete a spawned page from the middle of the form?
You can design a form to handle middle-page deletion, but spawning another page afterward can create duplicate field names. Deleting the last spawned page is the safer approach for the setup described here.
Why might the delete button fail?
Check the PDF's security permissions and whether your Acrobat environment permits page deletion. Also verify that the button action runs JavaScript and targets the intended page.




