![]() The actual value for the field is obtained from the value property. ![]() The first part of this code segment, this.getField("Calc2_A"), acquires the Field Object for the field named Calc2_A. The second thing to note is that the input field values are explicitly acquired. All calculation scripts must assign a value to the event.value variable. The value of this variable is assigned to the field when the calculation is completed. The first thing to notice is that the calculated value is assigned the variable event.value. event.value = ( this.getField("Calc2_A").value + this.getField("Calc2_B").value ) / this.getField("Calc2_C").value For example, the following code solves the same equation used in the simplified field notation example above. However, it also requires use of the full Acrobat JavaScript syntax which makes the calculations significantly longer. This option requires entering JavaScript and gives full access to all the fields (and other features) on the PDF file, as well as the rich math features in the JavaScript language. To create more complex logic or mathematics the third option, Custom calculation script must be used. Simplified field notation cannot operate on any field name that includes spaces or punctuation. Special characters are, in fact, the main reason calculations using this method fail, so let me repeat the restriction again. It also does not handle form field names that include punctuation or spaces. This notation is limited to calculations that only use the standard four math operators. Where Calc2_A, Calc2_B, Calc2_C are the names of text fieldsįigure 3: Syntax for using the simplified field notation ![]() ![]() It uses a notation similar to how a calculation would ordinarily be written, i.e., using the regular math symbols, + (addition), -(subtraction), *(multiplication) and /(division). The simplified field notation allows the creation of much more complex calculations. The predefined calculations are rather limited, for example, there is no division or subtraction. To use this option, simply select one of the calculations from the drop-down list, click on the Pick… button and select the fields to be used as inputs ( Figure 2). The first option on the Calculate tab is for the predefined calculations. The accompanying example file, SimpleCalcExample.pdf has one example for each. This data will, of course, be different for each of the different types of calculations. Select the desired calculation option: Predefined, Simplified field notation, or Custom calculation script.On the Text Field Properties dialog, select the Calculate tab.This action displays the Text Field Properties dialog ( Figure 2).įigure 2: Text-field calculation options/Selecting a predefined calculation Right-click the cursor on the text field where the calculation result will be displayed and select Properties from the popup menu.Figure 1 shows screen shots of both modes.įigure 1: Activating the Select Object Tool causes the form fields to be highlighted and the field names to be displayed. In Acrobat X, it is available in both normal operating mode and in form edit mode. In Acrobat 9 and earlier, this tool is accessed on the Advanced Editing toolbar. Calculations are only available for text fields and are accessed through the Text Field Properties dialog. In reality, all three are JavaScript, but for the first two, Acrobat builds the JavaScript code for us. Prerequisites: Familiarity with Acrobat ProfessionalĪcrobat provides three options for creating form-field calculations:
0 Comments
Leave a Reply. |