PDF Editing Issues

Create an Acrobat Calculated Field That Rounds Down

Emma BrownEmma Brown Nov 19, 2026 868 views

Question details

Create a PDF form calculation that divides two fields, rounds down, and displays 1 when the rounded result is zero.

Create an Acrobat Calculated Field That Rounds Down
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form needs a calculated output based on two numeric input fields.
Observed behavior
The output should show the rounded-down quotient, replacing a result of zero with 1.
Before you start

Open the PDF in an Acrobat version that can edit form fields, and confirm the exact names of the two input fields and the output field. Enable JavaScript in Acrobat preferences if it is disabled.

Solution 1Recommended

Add a custom calculation script to the output field

Use Acrobat JavaScript to divide the input values, round down, and replace a zero result with 1.

1
Open the form editor

In Acrobat, open the PDF and select All tools > Prepare a form. Make sure the form contains two input fields and an output field.

2
Open the calculation settings

Right-click the output field, select Properties, and open the Calculate tab. Select Custom calculation script and click Edit.

3
Enter the script

Paste this script, replacing Field A and Field B with your input field names: var aField = this.getField("Field A"); var bField = this.getField("Field B"); var aText = aField.valueAsString.replace(/^\s+|\s+$/g, ""); var bText = bField.valueAsString.replace(/^\s+|\s+$/g, ""); event.value = ""; if (aText !== "" && bText !== "") { var a = Number(aField.value); var b = Number(bField.value); if (isFinite(a) && isFinite(b) && b !== 0) { var result = Math.floor(a / b); event.value = result === 0 ? 1 : result; } }

4
Save and test the form

Click OK to close the script editor and field properties, then save the PDF. Enter values in Field A and Field B, including a zero numerator, a zero denominator, and blank inputs.

Add a custom calculation script to the output field
Blank and zero inputs: The script leaves the output blank if either input is blank, an input is not numeric, or the denominator is zero. A valid zero numerator produces 1.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easy to bring existing files into one workspace, but it does not replace Acrobat's custom JavaScript calculation workflow.

Open and review PDF forms alongside your other documentsCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight workspace for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Where do I enter the calculation script in Acrobat?

Select All tools > Prepare a form, right-click the output field, and choose Properties. On the Calculate tab, select Custom calculation script and click Edit.

What happens if the denominator is zero or an input is blank?

The script leaves the output field blank in either case. This avoids division by zero and prevents a blank input from being treated as a valid zero.

Does rounding down always mean rounding toward zero?

No. Math.floor rounds toward negative infinity. For example, Math.floor(-1.2) returns -2, while Math.floor(1.2) returns 1.

Will the calculation work in every PDF viewer?

Not necessarily. The viewer must support and allow Acrobat form JavaScript. Test the saved PDF in the viewer your recipients will use.