PDF Editing Issues

How to Prevent Adobe Acrobat PDF Barcode from Rounding Long Numbers

Nimra MalikNimra Malik Nov 3, 2026 869 views

Question details

The user needs to stop Adobe Acrobat PDF barcode scripts from altering or rounding long numerical values (like serial numbers).

How to Prevent Adobe Acrobat PDF Barcode from Rounding Long Numbers
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Generating barcodes via JavaScript calculations within a PDF document.
Observed behavior
Long numeric text-field values are treated as JavaScript numbers and converted into floating-point numbers, causing the barcode script to round them and lose precision.
Before you start

Ensure you have access to the JavaScript form editor in your PDF software and that your form fields are properly named before modifying the barcode calculation scripts.

Solution 1Recommended

Use the valueAsString Property in the JavaScript Code

Modify your PDF barcode calculation script to retrieve the form field data as a string, preventing the system from automatically treating it as a mathematical number.

When standard JavaScript `.value` calls are used to read numeric form fields, the application converts long digit sequences into floating-point numbers. Since floating-point numbers have limited mathematical precision, values like long serial numbers get truncated and rounded.

By switching to strict string handling, you ensure that the application reads the exact sequence of inputted characters without applying any mathematical conversion.

1
Access form editing mode

Open your PDF file containing the barcode and enter the form editing or form preparation mode.

2
Open barcode properties

Right-click the specific barcode form field and select 'Properties' from the context menu.

3
Locate the calculation script

Navigate to the 'Calculate' tab and click on the 'Edit' button next to your custom calculation script.

4
Modify the property

Find the line reading the text field, such as `this.getField("SerialNumberRow3").value`, and change `.value` to `.valueAsString`.

5
Save and test

Click 'OK' to save the script, exit form editing mode, and test the barcode generation to confirm the full number is accurately preserved.

Use the valueAsString Property in the JavaScript Code
Alternative Workaround: If you are working with an older script and are unable to change the property to `.valueAsString`, you can append a space to the value as a formatting workaround to force the system to treat it as text.
Powerful PDF Form Editor

Manage and Edit PDF Forms with WPS Office

WPS Office provides a highly capable PDF editor that allows you to manage interactive PDF forms, text fields, and document properties seamlessly. Enjoy smooth document processing and industry-standard format compatibility.

  1. 1. Launch WPS PDF: Open WPS Office on your device and select the 'PDF Edit' tool from the main workspace to begin.
  2. 2. Open the Document: Click 'Open' and import your interactive PDF form or document into the secure editor workspace.
  3. 3. Process the Forms: Navigate to the 'Form' tab to confidently interact with text fields, dropdowns, and checkboxes, ensuring your data is filled flawlessly.
Fully compatible with standard PDF forms, annotations, and interactive elements.Intuitive interface for filling and managing form fields without relying on complex scripting.Lightweight software architecture that quickly processes large and heavy PDF documents.Built-in cross-platform support for editing PDFs securely on Windows, Mac, iOS, and Android.
microsoft office alternative - wps office

Frequently Asked Questions

Why does JavaScript in PDFs automatically round long numbers?

Standard JavaScript handles numeric data using a double-precision floating-point format. When a numeric sequence exceeds 15 digits (known as the maximum safe integer limit), it loses precision and the lowest order digits are automatically rounded by the system.

Will appending a space corrupt my barcode scanner data?

Appending a space forces the PDF script to treat the number as a literal text string, which effectively solves the rounding issue. However, you must ensure that your external barcode scanning software is configured to ignore or trim trailing spaces to prevent data processing errors.

Does the valueAsString property work reliably on all PDF readers?

The `.valueAsString` property is widely supported in most modern, fully-featured PDF readers that support JavaScript form calculations. Basic or simplified web-based PDF viewers might not execute the JavaScript at all, falling back to static views.