PDF Editing Issues

How to Calculate Maximum Minus Minimum Values in Acrobat PDF Forms

Steve KSteve K Nov 3, 2026 869 views

Question details

The user needs to calculate the difference between the largest and smallest values among three specific form fields in an Acrobat PDF using JavaScript.

How to Calculate Maximum Minus Minimum Values in Acrobat PDF Forms
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating dynamic PDF forms that require custom mathematical calculations based on user input.
Observed behavior
The goal is to automatically display the calculated difference in a designated result field when the user inputs numbers into target fields, ensuring correct JavaScript syntax.
Before you start

Ensure you have the exact names of the form fields you want to calculate and that your PDF editor supports custom JavaScript execution in form fields.

Solution 1Recommended

Use a Custom Calculation Script with JavaScript

Write a custom calculation script using Math.max and Math.min to find the difference between the inputted field values.

Adobe Acrobat allows you to use JavaScript for advanced form field calculations. To find the difference between the highest and lowest values, you must retrieve the field values, convert them to numbers, and apply standard JavaScript Math functions.

It is critical to handle empty fields to prevent calculation errors before the user finishes filling out the form.

1
Open Field Properties

Right-click the target result field in Prepare Form mode and select 'Properties' from the context menu.

2
Navigate to the Calculate Tab

Click on the 'Calculate' tab within the Properties dialog box and select the 'Custom calculation script' option.

3
Enter the JavaScript Code

Click 'Edit' and enter code that retrieves your three fields, converts them using Number(), calculates the max and min, and sets event.value. For example: var v1 = Number(this.getField('Field1').value); var v2 = Number(this.getField('Field2').value); var v3 = Number(this.getField('Field3').value); if (v1 || v2 || v3) { event.value = Math.max(v1, v2, v3) - Math.min(v1, v2, v3); }

4
Save and Test

Click 'OK' to save your script, close the properties window, and test the calculation by entering numbers into the three designated input fields.

Use a Custom Calculation Script with JavaScript
Syntax Reminder: JavaScript is case-sensitive. Ensure that your field names exactly match those used in the getField() method and that 'event.value' is completely lowercase.
Efficient PDF Form Editing

Edit and Manage PDF Forms Easily with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to view, fill, and manage interactive PDF forms effortlessly. It is a lightweight, feature-rich alternative for all your document needs.

  1. 1. Download and Install: Get WPS Office from the official website and install it on your computer or mobile device.
  2. 2. Open Your PDF: Launch WPS PDF and open the PDF form you need to view, edit, or fill.
  3. 3. Interact with Forms: Click on the interactive fields to input your data; WPS PDF will handle standard form functionalities and data entry seamlessly.
Easily fill and interact with interactive PDF formsFully compatible with standard Adobe PDF document formatsConvert PDFs to Word, Excel, and other formats seamlesslyLightweight software with a clean, user-friendly interface
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PDF form calculation updating automatically?

Calculations may not update if the field calculation order is incorrect. In Acrobat, go to the Prepare Form tool, select 'More' > 'Clear Form', and check 'Calculation Order' to ensure the fields are calculated in the correct sequence.

How do I ignore empty fields in my maximum and minimum calculation?

You can add a condition in your JavaScript to check if a field is empty (e.g., if(field.value !== '')) before including it in the Math.max or Math.min array. Filtering out empty strings prevents them from being incorrectly evaluated as zero.

Can I perform this calculation without using JavaScript?

No, the built-in PDF calculation options only support basic sum, product, average, minimum, or maximum across selected fields. Combining operations into a single 'Maximum minus Minimum' result requires a custom JavaScript calculation.