Locate JavaScripts

Whether you write scripts in your own documents, or browse files for scripts to examine, you first need to know where to look for JavaScripts. In Nitro Pro you can find JavaScripts in the following locations:

Field scripts

JavaScripts can be used with all field types. In all fields you can add scripts in the Set Actions properties. In signature fields you can add JavaScripts in both the Set Action properties and in the Signed properties. By far the most opportunity you have for adding scripts in field properties is with text fields. In text fields you can add scripts to:

  • Format properties. Open the Format properties and select Custom from the Select format category drop down menu. JavaScripts are added to create a Custom Format Script and Custom Keystroke Script.
  • Validate. Open the Validate properties and select Use custom validation script to add a JavaScript to validate field data.
  • Calculate. The Calculate properties are likely to be the most frequent area where JavaScripts are created. You can write scripts in two areas. Click the Simplified field notation button and you can write scripts using syntax similar to spreadsheet formulas. Click the Custom calculation script and you can write JavaScripts to calculate field data.
  • Add Action. Like the other fields, text fields support the Run JavaScript action type.

JavaScript console

You can open the JavaScript Console and write a script that doesn’t belong to any field or element. Scripts written in the JavaScript Console can be used to test routines and debug code.

Document Actions

Opening, saving and printing PDFs are all document actions. JavaScripts can be written when these actions occur. To add a Document Action, go to the Forms ribbon tab, in the JavaScript group, click Document Actions.

Document level JavaScripts

A document level JavaScript can be a function that other scripts call in subroutines. These scripts are contained at the document level and can be executed by another script or when opening a file.

Folder level JavaScripts

A folder level JavaScript is located outside of the PDF file (in a .js file) and can be used by more than one PDF. When Nitro Pro is opened the scripts are run.