PDF Editing Issues

How to Preserve Leading Zeros in an Acrobat PDF QR Code

Huda QurayshiHuda Qurayshi Nov 2, 2026 869 views

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.

How to Preserve Leading Zeros in an Acrobat PDF QR Code
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).
Before you start

Ensure you have permission to edit the PDF form fields and access to the custom calculation scripts or barcode properties within your PDF editor.

Solution 1Recommended

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.

1
Open form editing mode

Open your PDF in Adobe Acrobat, navigate to 'Tools', and select 'Prepare Form' to enter the editing mode.

2
Access QR code properties

Right-click the QR code field that is dropping the zeros and select 'Properties' from the context menu.

3
Navigate to the Calculate tab

In the Properties dialog box, click on the 'Calculate' tab to modify how the QR code gathers its data.

4
Add a custom calculation script

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;

5
Save and test

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'.

Add a Text Prefix to the QR Code Value Using JavaScript
Alternative Fix: If you do not want a visible prefix in your final decoded data, you can sometimes append a hidden whitespace character, though a clear alphanumeric prefix like 'SN-' or 'ID:' is universally reliable across all barcode scanners.

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. 1. Launch WPS Office: Open WPS Office and select the 'PDF' module from the main home screen.
  2. 2. Open your document: Import the PDF form you need to view, fill out, or edit.
  3. 3. Use Form tools: Navigate to the 'Form' tab to interact with text fields, checkboxes, and drop-down menus seamlessly.
  4. 4. Save your changes: Click 'Save' to ensure all your form data is securely stored in standard PDF format.
Easily fill and manage interactive PDF form fieldsFully compatible with standard Adobe PDF document formatsLightweight and user-friendly alternative for daily PDF editingBuilt-in tools for annotations, text editing, and digital signatures
QA img-9

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.