Field scripts
You can add a script to any field type. Each field type supports scripts in its Set Actions properties. Signature fields also support scripts in their Signed properties.
Text fields offer the most options for scripts. In a text field, you can add a script to:
- Format properties. Open the Format properties, and select Custom from the Select format category list. Use this option to create a custom format script and a custom keystroke script.
- Validate. Open the Validate properties, and select Use custom validation script. Use this option to validate field data.
- Calculate. Use this option to calculate field data. You can write a script in two ways:
- Click Simplified field notation to write a formula. This method uses syntax similar to spreadsheet formulas.
- Click Custom calculation script to write a full JavaScript.
- Add Action. Like other field types, text fields support the Run a JavaScript action.
JavaScript console
The JavaScript Console holds a script that is not attached to a field or other document element. Use the console to test routines and debug code.
To add a document action:
- On the Forms ribbon, in the Document Setup group, click the arrow besides the JavaScript button and select Console

Document Actions
Opening, saving, and printing a PDF are document actions. You can attach a JavaScript to each of these actions.
To add a document action:
- On the Forms ribbon, in the Document Setup group, click the arrow besides the JavaScript button and select Document Actions

- In the Set Document Actions window, select the document action and click Edit to enter the script or clear to remove it

Document level JavaScripts
A document-level JavaScript stores a function. Other scripts in the same document can call this function.
The document stores this type of script. You can run the script from another script, or when a user opens the file.
To write a document level JavaScript:
- On the Forms ribbon, in the Document Setup group, click the arrow besides the JavaScript button and select Document Actions

- Click New, and type a name for the JavaScript

- In the JavaScript Editor dialog, enter your code

- Click Execute and OK
Folder level JavaScripts
A folder-level JavaScript is a script file (.js) that is stored outside the PDF file. More than one PDF can use this type of script.
To add or edit a folder level JavaScript
-
On the Forms ribbon, in the Document Setup group, click on the arrow next to JavaScript, and then select Folder Level

-
The directory where the JavaScripts are stored opens
-
Add a new JavaScript file to the folder, or edit an existing file
Nitro PDF Pro runs folder-level scripts when the application starts.