How to Preserve Leading Zeros in an Acrobat PDF QR Code
Question details
The user needs to maintain leading zeros in a QR code generated from a numeric PDF form field, preventing the encoder from automatically converting the value to a standard integer.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Generating a QR code within a PDF document based on data entered into a form field that contains leading zeros (e.g., 001).
- Observed behavior
- The form field displays the leading zeros correctly, but the resulting QR code drops them and encodes only the integer value (e.g., 1).
Ensure you have permission to edit the PDF form fields and access to the custom calculation scripts or barcode properties within your PDF editor.
Add a Text Prefix to the QR Code Value Using JavaScript
Force the QR code encoder to treat the data as a text string rather than a numeric value by adding a non-numeric character or prefix.
Acrobat's barcode encoder automatically switches to Numeric mode if the input string consists exclusively of digits. In Numeric mode, it reformats strings like '001' into the integer '1'.
By prepending a text character (such as 'ID:') to the value before it gets encoded, you force the generator to use Alphanumeric or Byte mode, which accurately preserves the exact string of characters including your leading zeros.
Open your PDF in Adobe Acrobat, navigate to 'Tools', and select 'Prepare Form' to enter the editing mode.
Right-click the QR code field that is dropping the zeros and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Calculate' tab to modify how the QR code gathers its data.
Select 'Custom calculation script' and click 'Edit'. Enter a JavaScript snippet that adds a text prefix. For example: event.value = "ID:" + this.getField("YourNumericField").valueAsString;
Click 'OK', close the properties dialog, and exit form editing mode. Enter a value like '001' in the source field and verify the QR code now encodes 'ID:001'.

Edit and Manage PDF Forms Seamlessly with WPS Office
While advanced JavaScript barcode generation is highly specific, WPS Office provides a robust, built-in PDF editor that allows you to easily fill, create, and manage standard PDF forms without encountering complex encoding errors.
- 1. Launch WPS Office: Open WPS Office and select the 'PDF' module from the main home screen.
- 2. Open your document: Import the PDF form you need to view, fill out, or edit.
- 3. Use Form tools: Navigate to the 'Form' tab to interact with text fields, checkboxes, and drop-down menus seamlessly.
- 4. Save your changes: Click 'Save' to ensure all your form data is securely stored in standard PDF format.

Frequently Asked Questions
Why do leading zeros disappear in my PDF QR code?
Standard PDF barcode encoders automatically optimize data. If they detect only numbers, they switch to a numeric encoding mode that treats the string as a mathematical integer, causing leading zeros to be dropped.
Can I simply format the source PDF form field as text?
Formatting the source field as text often isn't enough because the QR code encoder evaluates the final string value. If that value contains only digits, it still applies numeric compression. You must introduce a non-numeric character to bypass this.
Does this issue affect other types of barcodes in PDFs?
Yes, this optimization behavior can also occur with other formats like Code 128 or Data Matrix when generating barcodes natively inside a PDF using calculation scripts.




