How to Keep Leading Zeros in PDF Drop-Down Export Values
Question details
The user needs to prevent PDF software from automatically stripping leading zeros from drop-down field export values.

- Product
- Adobe Acrobat / PDF Editors
- Device & OS
- not provided
- Scenario
- Creating or editing a PDF form with calculation scripts that reference a drop-down menu containing numerical codes with leading zeros.
- Observed behavior
- The PDF editor treats export values like '023' as numbers, automatically stripping the leading zero and displaying '23' instead.
Ensure you have access to the JavaScript calculation properties of your PDF form fields and verify the exact field names you are referencing.
Use 'valueAsString' in the Calculation Script
Modify your JavaScript calculation to treat the drop-down export value as a text string instead of a mathematical number, which preserves formatting like leading zeros.
When a calculation script uses standard '.value', the PDF processor interprets numbers mathematically, stripping away any leading zeros. By extracting the value as a string, you force the software to recognize the export code as plain text.
In your PDF editor's form preparation mode, right-click the destination text field where the drop-down value will be displayed and select 'Properties'.
Click on the 'Calculate' tab in the Properties dialog box, then select the 'Custom calculation script' option.
Click the 'Edit' button and update your script to use the valueAsString property. For example, replace event.value = this.getField("DIVISIONCODE").value; with event.value = this.getField("DIVISIONCODE").valueAsString;
Click 'OK' to save the script, close the Properties box, and exit form editing mode. Select a drop-down option to verify the leading zero remains intact.

Create and Edit PDF Forms Easily with WPS Office
WPS PDF provides powerful tools for viewing, editing, and managing PDF forms. You can easily fill out interactive forms, modify form data, and maintain strict text formatting without complex workarounds.
- 1. Open Your PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Access Form Tools: Navigate to the 'Edit' or 'Form' tab to interact with text fields, drop-down menus, and checkboxes.
- 3. Modify and Save: Fill in the required fields preserving your specific formatting, then click 'Save' to keep your data intact.

Frequently Asked Questions
Why does my PDF remove leading zeros from numbers?
Most PDF software automatically interprets numeric inputs as standard mathematical numbers. Since leading zeros hold no mathematical value, they are stripped unless the field is specifically formatted as text or extracted as a string.
Can I just format the PDF field as text to keep the zero?
Formatting the destination field as 'Text' may help in some manual entry cases, but if a calculation script is transferring the data using the standard '.value' property, the system still processes it mathematically first. Using '.valueAsString' overrides this automated behavior.
Does this JavaScript fix work in all PDF readers?
Yes, standard JavaScript properties like valueAsString are part of the core interactive PDF specification. Forms configured this way will function correctly in Acrobat, WPS PDF, and other compliant PDF readers.
How do I format numbers with leading zeros without scripting?
If you aren't using calculation scripts to automatically populate fields, you can simply set the field's format category to 'None' or 'Text' in its properties, allowing you to manually type and retain leading zeros.




