PDF Editing Issues

How to Truncate PDF Form Calculation Results to Two Decimal Places

Maira MehtabMaira Mehtab Nov 5, 2026 870 views

Question details

The user needs to truncate a calculated VAT or total value in a PDF form to exactly two decimal places (e.g., showing 51.87 instead of 51.88) without the default rounding applied by standard PDF form software.

How to Truncate PDF Form Calculation Results to Two Decimal Places Without Rounding
Product
PDF / Adobe LiveCycle Designer
Device & OS
not provided
Scenario
Calculating tax or financial totals using formulas in an interactive PDF form.
Observed behavior
The form's default calculation automatically rounds the value up to two decimal places (e.g., 51.875 becomes 51.88) instead of truncating it to 51.87.
Before you start

Ensure you have access to edit the form field properties of your interactive PDF and are comfortable entering basic JavaScript into the calculation script editor.

Solution 1Recommended

Use Custom JavaScript to Truncate Values

Replace the default display rounding with a JavaScript formula that mathematically truncates the value to two decimal places.

Default PDF form calculation settings automatically round numbers to the nearest decimal based on financial standards. By switching the calculation language to JavaScript, you can use the Math.floor() function to accurately cut off trailing decimals without rounding up.

1
Select the Result Field

Open your PDF form editor, navigate to the specific text field where the calculation result is displayed, right-click, and select Properties.

2
Switch the Calculation Language

Navigate to the Calculate tab in the Properties window. If you are using a specific form designer, ensure the scripting language is changed from 'FormCalc' to 'JavaScript'.

3
Enter the Truncation Script

Select 'Custom calculation script' and input your truncation logic. For example: var dec = Number(this.getField("SubTotal").value) * 5 / 100; event.value = Math.floor(dec * 100) / 100;

4
Format the Display Pattern

Navigate to the Format tab of the same field and set the format category to Number with 2 decimal places. This ensures that even truncated values will correctly display trailing zeros (e.g., 51.80).

Use Custom JavaScript to Truncate Values
Handling Negative Values: If your calculation might result in negative numbers, be aware that Math.floor() rounds down to the next lowest integer. You may need to use conditional logic or the Math.trunc() function if it is supported by your PDF reader's JavaScript engine.
Advanced PDF Form Editing

Manage and Edit PDF Forms with WPS Office

WPS Office offers a comprehensive PDF editor that allows you to manage interactive PDF forms, edit field properties, and ensure your documents are formatted perfectly for professional use.

  1. 1. Launch WPS PDF: Open WPS Office and select the PDF module to load the built-in PDF editor.
  2. 2. Open Your Document: Browse your files and open the existing interactive PDF form you wish to modify.
  3. 3. Access Form Tools: Navigate to the Form tab on the top ribbon to view and interact with all form fields within the document.
  4. 4. Modify Field Properties: Double-click any form field to adjust its appearance, data format, or calculation properties.
Edit and manage interactive PDF form fields seamlesslyHigh compatibility with Adobe PDF and Microsoft Office formatsLightweight software with an intuitive, user-friendly interfaceComprehensive tools for filling, signing, and printing PDFs
microsoft office alternative - wps office

Frequently Asked Questions

How do I handle negative numbers when truncating PDF calculations?

The Math.floor() function rounds down to the lowest number, which can distort negative values (e.g., -51.875 becomes -51.88). Instead, use a custom JavaScript condition or the Math.trunc() function if your PDF reader's JavaScript engine supports it.

Can I truncate numbers using FormCalc instead of JavaScript?

FormCalc defaults to standard rounding rules for its display patterns. While complex string manipulation is possible within FormCalc, switching the calculation language to JavaScript and using mathematical truncation is much more reliable and straightforward.

Why does my truncated PDF calculation drop the trailing zero?

Mathematical functions like Math.floor() handle values as raw numbers, dropping non-essential trailing zeros (e.g., converting 51.80 to 51.8). To fix this, set the text field's format properties to explicitly display two decimal places in your PDF editor.