Nitro PDF Professional: Create and change PDFs with the original Acrobat alternative.


Download the 14-day free trialBuy online now


Writing calculation scripts

Any form you create that requires calculations is likely to require custom calculation scripts. The options you have available with preset calculation formulas are limited to simple multiplication and addition. Any other kind of calculation you need requires writing a script.

To write a calculation script:

  1. Open the properties of a Text field and click Calculate.
  2. Open the Set Action drop down menu and select Run JavaScript.
  3. Click Add to open the JavaScript Editor.
  4. Type the code for your script. In the example below, a simple routine is created to calculate sales tax at a 7.25 % rate. The code used is:
  5. var f = this.getField("subtotal");
    event.value = Math.round(f.value * 7.25)/100;

  6. Click OK.

Tip: This script presumes you have another field on the page named: subtotal.