How to Export PDF Form Field Names and Tooltips in Document Order
Question details
The user needs to export PDF form field names and tooltips using JavaScript, specifically omitting fields with blank tooltips and ordering the output by physical document layout rather than alphabetically.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Running a custom JavaScript routine to extract metadata from PDF form checkboxes and text fields.
- Observed behavior
- The default script lists fields in alphabetical order and fails or appends unwanted blank data when a field lacks a defined tooltip.
Ensure you have access to a professional PDF editor with form-editing capabilities and a built-in JavaScript console for executing custom scripts.
Update JavaScript to Omit Blank Tooltips
Modify your data collection loop with a conditional statement to ignore fields that do not have an assigned tooltip.
By default, iterating through PDF form fields retrieves all elements, including those lacking metadata. Applying an IF condition ensures your output remains clean and prevents script execution errors.
Launch your PDF editor, navigate to the Tools menu, and open the JavaScript Debugger or Console window.
Find the section of your script that appends field data to your output variable (e.g., Data += cName + ...).
Replace the generic append line with the following code: if (cToolTip != "") Data += cName + "; " + cToolTip + "\n";
Run the updated JavaScript. The console output will now correctly skip any form fields that do not contain a tooltip.

Achieve Visual Document Order
Since standard methods do not reflect physical page layout, use coordinate sorting or manual form property copying to achieve visual order.
Manage PDF Form Fields Effectively with WPS Office
WPS Office offers a comprehensive PDF editor that simplifies creating, editing, and managing interactive form fields. You can easily modify tooltips, arrange visual layouts, and handle PDF properties without relying heavily on complex custom scripts.
- 1. Open Your Document in WPS PDF: Launch WPS Office and open your interactive PDF document containing the form fields.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to reveal the interactive field editing tools.
- 3. Edit Field Properties: Double-click any checkbox or text field to open its properties dialog, where you can directly add or modify the Name and Tooltip.
- 4. Organize and Save: Visually arrange your fields as needed, then save the document to preserve the layout and metadata.

Frequently Asked Questions
Why does the default PDF JavaScript export list fields alphabetically?
When extracting fields using standard field object iterations in JavaScript, the PDF engine typically processes them based on their internal hierarchical names, which defaults to an alphabetical arrangement rather than physical placement.
Can I easily sort PDF form fields by physical location?
There is no single built-in command to export by physical layout. You must either write a custom script that reads and sorts the 'rect' coordinates of each field or copy and paste the fields into a new document in the desired sequence.
What happens if my PDF JavaScript encounters a field with no tooltip?
If you append the tooltip property without checking if it exists, the script may output a blank space, 'null', or 'undefined' for that specific field, which can misalign your exported data list.
How do I add tooltips to PDF form fields?
Open your document in a capable PDF editor like WPS Office, enter the form editing mode, double-click the field to open its properties, and enter your descriptive text into the 'Tooltip' box under the General tab.




