Calculate field data
Calculations are one of the most significant functions of electronic form. For instance, it can combine values from form fields and present the calculation results on a Text Field or Combo Box.
You can go to the Calculate tab in the Text Field and Combo Box Properties dialog box, in which you can select a predefined calculation method and the fields affected thereof.
To create a calculation
-
Open a PDF file and do one of the following to call out the Text Field Properties dialog box:
-
-
Choose Form > Form > Text Field. On the page, drag a rectangle where you want the text field to appear and the dialog box pops up.
-
Using Select tool, double-click on the text field intended to show calculation result.
-
Using Select tool, right-click on the text field intended to show calculation result and select Properties….
-
In the Text Field Properties dialog box, set General properties for field attributes.
-
Select Options and choose an Alignment type to determine at which position the result displays in the calculation field. For example, select Right from the options to align the values to the right.
-
In Format, click Number and then click the Decimal drop-down menu. Select the number of digits displayed to the right of the decimal point.
-
In Calculate, select a predefined calculation option from the drop-down menu:
-
Select as the sum (+) of selected fields to sum a group of data.
-
Select as the product (x) of selected fields to multiply values.
-
Select as the average of selected fields to average a group of values.
-
Select as the minimum of selected fields to present the minimum value among a group of fields.
-
Select as the maximum of selected fields to present the maximum value among a group of fields.
-
Using simplified field notation. This custom calculation uses regular math symbols, + (addition), - (subtraction), * (multiplication) and / (division), and field names are used as operands. For example, if you want to calculate the product of the sum of two numbers and subtraction of two numbers, enter (Text1+Text2)*(Text1-Text2).
-
Using custom calculation script. This custom calculation uses JavaScript for carrying out more complex calculations and gives full access to all the fields in the PDF. For example, to calculate the product of the sum of two numbers and subtraction of two numbers, enter eevent.value=((this.getField("Text1").value+this.getField("Text2").value))*((this.getField("Text1").value-this.getField("Text2").value));
-
If you have selected a predefined calculation in the previous step, click Pick … , select or deselect the checkboxes to decide which field is involved in calculation, and click OK; if you have selected a custom calculation, click Edit …, enter script in the JavaScript editor, and click OK.
-
Click Close. When you enter numbers in designated fields, the calculation-enabled field displays the result value as per the chosen type of calculation in step 4.
Set Field Calculation Order
When you create multiple calculations in a form, you can modify the calculation order to get correct results.
For instance, in order to use the result obtained from calculating form field A and B to calculate the value of a third form field C, A and B must be calculated together first to get the correct final results.
-
Choose Form > Set Field Calculation Order to open Calculate Fields dialog box, which lists all calculable fields in the form.
-
To change the field calculation order, select the field from the list, and click the Up or Down button as needed.
-
Click OK.
Note: when you create or test form fields, Right PDF Editor will automatically perform all calculations. You can go to Preferences > Forms and uncheck Automatically calculate field values to disable this.