How to Fix Acrobat Calculation Format Errors in Percentage Fields
Question details
The user needs to prevent field-format errors when applying a calculation to a percentage field based on currency input values in a PDF form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or modifying an interactive PDF form where a percentage result is calculated from other fields, such as dividing the difference between two currency fields by a base field.
- Observed behavior
- When the denominator field is empty or zero, the calculation attempts to divide by zero, resulting in an 'Infinity' value which produces a field-format error because it cannot be formatted as a percentage.
Before editing your form, ensure you have the necessary editing permissions for the PDF document and verify the exact names of your input fields (e.g., 'E9' and 'H9') to reference them correctly in your script.
Use a Custom JavaScript Calculation to Check for Zero Values
Implement a custom JavaScript snippet in the field properties to check if the denominator is zero or empty before performing the division, preventing the invalid 'Infinity' format error.
By default, basic simplified field notations do not handle division by zero automatically. When a calculation divides by an empty or zero value, it returns an invalid result that the percentage format cannot process. Replacing the simple formula with a conditional custom script ensures the field remains blank unless valid numbers are entered.
Open your PDF document in Adobe Acrobat, navigate to the Tools menu, and select the 'Prepare Form' option to enable field editing.
Right-click on the result field (the one formatted as a percentage) and select 'Properties' from the context menu.
Go to the 'Calculate' tab in the Properties window. Choose the option 'Custom calculation script' and click the 'Edit' button.
Enter the following code, replacing 'H9' and 'E9' with your actual field names: var v1 = Number(this.getField('H9').valueAsString); var v2 = Number(this.getField('E9').valueAsString); if (v2 == 0) event.value = ''; else event.value = (v2 - v1) / v2;
Click 'OK' to save the script, then click 'Close' on the Properties window. Enter test values in your form to confirm the percentage calculates correctly and zero-values no longer trigger an error.

Create and Edit PDF Forms Easily with WPS Office
WPS Office provides a powerful, built-in PDF editor that makes it easy to handle interactive forms, fillable fields, and document calculations. It simplifies complex PDF tasks into an intuitive interface.
- 1. Install WPS Office: Download and install the free WPS Office suite from the official website.
- 2. Open Your PDF: Launch WPS PDF and open your form document.
- 3. Edit Form Fields: Navigate to the 'Form' tab on the top ribbon to easily insert, adjust, and configure text fields, checkboxes, and calculation properties.
- 4. Save and Export: Once your fields are configured, save the interactive PDF to share it securely with others.

Frequently Asked Questions
Why does my PDF percentage field show an error when the input is empty?
When an input field used as a denominator is empty, the PDF viewer interprets its value as zero. Attempting to divide by zero yields 'Infinity', which is an invalid value for a field formatted to display a numeric percentage, thus throwing a format error.
How do I access custom calculation scripts in a PDF form?
To access custom calculation scripts, open the form in edit mode, right-click the target field, and select 'Properties'. Then navigate to the 'Calculate' tab, select 'Custom calculation script', and click 'Edit' to enter your JavaScript code.
Can I use basic math operations instead of JavaScript for PDF calculations?
Yes, you can use pre-defined math operations like Sum or Product, or 'Simplified field notation' for basic formulas. However, these basic methods do not have the logical conditions needed to prevent division by zero errors, which is why custom JavaScript is required for certain dynamic calculations.




