PDF Editing Issues

Calculate and Round a PDF Form Field in Adobe Acrobat

Muhammad TalhaMuhammad Talha Nov 24, 2026 868 views

Question details

Calculate a consumption rate from two PDF form fields, display it to one decimal place, and ensure fields calculate in the correct order.

Calculate and Round a PDF Form Field in Adobe Acrobat
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A PDF form divides a quantity field by an engine-hours field to calculate a consumption rate.
Observed behavior
The desired result is a correctly ordered calculation displayed to one decimal place, with no result when the divisor is zero.
Before you start

Open the form in Adobe Acrobat with form-editing tools available. Check the exact names of the quantity, hours, and result fields in Prepare a Form; the example uses QTYCC1 and ENGHRS1 for the source fields.

Solution 1Recommended

Add a calculation script and set the field order in Acrobat

Use a custom Acrobat JavaScript calculation to divide the fields and display the result to one decimal place.

1
Open the result field

In Acrobat, open All tools > Prepare a form, then double-click the consumption-rate field to open its properties.

2
Add the script

On the Calculate tab, select Custom calculation script and click Edit. Enter: var qty = Number(this.getField("QTYCC1").valueAsString); var hours = Number(this.getField("ENGHRS1").valueAsString); event.value = hours == 0 ? "" : (qty / hours).toFixed(1); Replace the field names if yours differ.

3
Check the display format

On the result field's Format tab, choose None so another field format does not override the script's one-decimal display. Close the field properties.

4
Set calculation order

In Prepare a Form, open More > Set Field Calculation Order. If the quantity field is itself calculated, move it before the consumption-rate field, then confirm the order.

5
Test the form

Use Preview in Prepare a Form and enter values in the quantity and hours fields. Confirm that the result shows one decimal place and is blank when hours is zero, then save the PDF.

Add a calculation script and set the field order in Acrobat
Rounding upward: The script uses toFixed(1) for a one-decimal display. To always round the quotient upward to a whole number instead, replace (qty / hours).toFixed(1) with Math.ceil(qty / hours).
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility, making it easy to move existing files into one workspace. Use Acrobat to configure the custom PDF form script and calculation order described above.

Open and work with PDF files alongside office documents.Compatible with common Microsoft Office formats, including DOCX, XLSX, and PPTX.Familiar document tools help ease the transition from Microsoft Office.
microsoft office alternative - wps office

Frequently Asked Questions

Why is the calculated field blank when hours is zero?

The script checks whether ENGHRS1 is zero and sets event.value to an empty string to avoid division by zero. Enter a nonzero hours value to calculate the rate.

How do I make sure the quantity calculates before the rate?

In Acrobat's Prepare a Form tool, choose More > Set Field Calculation Order and place the calculated quantity field before the consumption-rate field.

Does toFixed(1) always round upward?

No. toFixed(1) formats the result to one decimal place. Use Math.ceil(qty / hours) if the result must always round upward to a whole number.

Is Acrobat form scripting written in Java?

No. Acrobat form calculations use JavaScript, which is a different language from Java. Add the script through the result field's Calculate tab.