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


Download the 14-day free trialBuy online now


Finding 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 PDF Professional 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 Run 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.
    • Set Action. Set Action. Like the other fields, text fields support the Run JavaScript action type.
  • Bookmarks. Open a context menu on a bookmark and select Set Action. Select Run JavaScript from the drop down menu, click Add, and the JavaScript Editor opens.
  • Links. Open a context menu on a link and select Set Action. Select Run JavaScript from the drop down menu, click Add, and the JavaScript Editor opens.
  • 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 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. Select Document > JavaScript > Document JavaScripts to open the JavaScripts Functions window where JavaScripts are added.
  • Document Actions. Opening, saving and printing PDFs are all document actions. JavaScripts can be written when these actions occur. To add a Document Action, select Document > JavaScript > Set Document Actions. To write a script when a Close is requested, a Save is requested, a Save is completed, a Print is requested, or a Print is completed, double-click on the respective item to assign the JavaScript. The JavaScript panel opens where you add the code.

Tip: Simplified field notation is only available in the Calculate properties in text fields.