PDF Editing Issues

How to Add Rounded Values Correctly in AEM Forms Designer

Kushani NimanthikaKushani Nimanthika Nov 3, 2026 869 views

Question details

The user needs to ensure that PDF form fields calculate totals using explicitly rounded values, rather than relying on unrounded source data that only appears rounded visually.

How to Add Rounded Values Correctly in AEM Forms Designer
Product
AEM Forms Designer
Device & OS
not provided
Scenario
Setting up JavaScript calculation scripts for interactive PDF form fields that involve percentages, annual terms, and numeric aggregation.
Observed behavior
The form engine calculates totals using exact unrounded underlying values, which causes a mismatch when those totals are displayed alongside fields formatted to show rounded numbers.
Before you start

Ensure you have access to the field properties and JavaScript calculation script editors for your PDF form fields before modifying the formulas.

Solution 1Recommended

Apply Math.round() in Your JavaScript Calculation Script

Use the JavaScript Math.round() function within the form's calculation script to explicitly round values before they are added or multiplied.

JavaScript calculates using the exact underlying mathematical value by default, even if the field format is set to display zero decimal places. Explicitly rounding the values during the mathematical operation prevents adding unrounded decimals that cause final totals to appear incorrect.

1
Open Field Properties

Right-click the target form field in your designer, open the field properties, and navigate to the calculation script editor.

2
Define Order of Operations

Use explicit parentheses to define the correct order of operations, isolating the specific steps you want to round first.

3
Apply Math.round()

Wrap the specific part of the equation you want to round with the rounding function. For example: event.value = Math.round(this.getField('YourField').value * 0.10) * 2;

4
Round Individual Components

If you are adding multiple multi-year values, round each component separately before the final addition: event.value = Math.round(Field1 * 0.10) + Math.round(Field2 * 0.10);

5
Configure Visual Format

Navigate to the Format tab in the field properties, select Number or Currency, and configure your desired decimal places to match the output of your calculation.

Apply Math.round() in Your JavaScript Calculation Script
Rounding Functions: Use Math.round() for standard rounding to the nearest integer, or Math.ceil() if your policy requires rounding upward regardless of the decimal value.

Manage and Edit Interactive PDF Forms with WPS Office

WPS Office features a robust PDF editor that allows you to seamlessly fill, manage, and interact with PDF form fields. It is a lightweight, highly compatible alternative for handling document calculations and standard interactive elements.

  1. 1. Open WPS Office: Launch the WPS Office application and open your PDF document using the WPS PDF editor.
  2. 2. Access PDF Form Tools: Navigate to the Form tab on the top ribbon to view, fill, or interact with available form fields.
  3. 3. Save Document: Once your values are entered and the background calculations are executed, click Save to preserve the updated form data.
Easily interact with formatted PDF form fieldsHighly compatible with standard PDF calculation outputsLightweight, fast, and completely free for basic editing needsAll-in-one comprehensive suite for PDF, Word, Excel, and Presentation
QA img-9

Frequently Asked Questions

Why do my PDF form totals look incorrect when adding rounded numbers?

The form calculates using the exact, unrounded underlying data (such as 2.54) rather than the displayed rounded number (like 3). You must use the Math.round() function in your script to round the underlying values before adding them together.

What is the difference between formatting a field and rounding a calculation in PDF forms?

Formatting a field only changes how the number is displayed visually on the screen (e.g., hiding decimals), whereas rounding via a calculation script actually alters the underlying mathematical value used in subsequent formulas.

How do I round a PDF form calculation upward instead of to the nearest integer?

Use the JavaScript function Math.ceil() instead of Math.round() in your form calculation script. This forces the value to always round up to the next highest whole integer.