PDF Editing Issues

How to Show Spawn and Delete Buttons Only on the Last PDF Page

Camila MilosovichCamila Milosovich Nov 5, 2026 869 views

Question details

Configure a PDF form so that specific interactive buttons, such as Spawn and Delete, are hidden on all pages except the final page.

How to Show Spawn and Delete Buttons Only on the Last PDF Page
Product
PDF
Device & OS
not provided
Scenario
Creating or modifying an interactive PDF form with JavaScript-controlled buttons that should only appear at the end of the document.
Observed behavior
The Delete button currently appears on pages where it should be hidden, requiring a script to restrict its display dynamically based on the current page number.
Before you start

Ensure your PDF editor supports JavaScript execution and advanced form field editing before modifying button visibility settings.

Solution 1Recommended

Use Page-Based JavaScript to Control Button Visibility

Apply a custom JavaScript script to the PDF document to automatically hide the buttons on all pages and reveal them only on the final page.

By using a page-level script, you can dynamically evaluate the current page number against the total number of pages in the document. This ensures that even if pages are spawned or removed, the buttons will consistently only appear on the final page.

1
Open Form Editing Mode

Open your interactive PDF in your PDF editor and enter the 'Form' or 'Prepare Form' mode to view all interactive fields.

2
Access Button Properties

Right-click the Spawn or Delete button you want to modify and select 'Properties' from the context menu.

3
Add a JavaScript Action

Navigate to the 'Actions' tab, choose 'Page-level scripts' or 'Run a JavaScript' as the trigger action, and click 'Add'.

4
Input the Visibility Logic

Enter a script that checks if the current page is the last page (e.g., comparing pageNum to numPages - 1). Set the button's display property to 'display.visible' if true, and 'display.hidden' if false.

5
Test Document Functionality

Save the changes, exit form editing mode, and scroll through the document to verify the buttons only appear on the final page.

Use Page-Based JavaScript to Control Button Visibility
Viewer Compatibility: JavaScript support varies significantly across different PDF viewers. Always test your interactive forms in widely used, fully featured desktop programs rather than web browser PDF viewers to ensure reliable functionality.
Advanced PDF Form Editing

Manage Interactive PDF Forms Easily with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to manage form fields, edit text, and handle interactive documents with ease.

  1. 1. Open Your Document: Launch WPS Office and open your PDF document containing the interactive forms.
  2. 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to access the interactive field tools.
  3. 3. Modify Field Properties: Select the specific button or field you want to adjust and double-click to open its properties menu.
  4. 4. Save Your Form: Once your fields are configured, simply click the 'Save' icon to apply your changes directly to the PDF.
Easily insert, edit, and manage PDF form fields and buttonsHigh compatibility with standard PDF interactive elements and formatsFree and lightweight alternative to heavy PDF software
microsoft office alternative - wps office

Frequently Asked Questions

Why are my PDF form JavaScript buttons not working in browsers?

Most web browsers' built-in PDF viewers (like Chrome or Edge) have limited or no support for PDF JavaScript. It is strongly recommended to open interactive forms in dedicated desktop software to ensure scripts execute properly.

What is the JavaScript property used to hide a button in a PDF?

You can hide a form field by setting its display property to hidden, typically using the code: getField('buttonName').display = display.hidden;.

Can I apply this visibility logic to other form fields like text boxes?

Yes, the same JavaScript logic used for buttons can be applied to text boxes, dropdowns, or any other interactive form field by referencing the field's specific name in your script.