Skip to content

Add or Edit Document-level JavaScript

Use JavaScript to add interactive features to a PDF. You can also use JavaScript to create calculation formulas and other dynamic functions.

A document-level JavaScript stores functions that other scripts in the PDF can reuse. You can also use a document-level JavaScript to run an action when a user opens the file.



To write a document level JavaScript

  1. Open the PDF in Nitro PDF Pro
  2. On the Forms ribbon, in the Document Setup group, click the arrow besides the JavaScript button and then click Document LevelDocument setup
  3. Click New, and type a name for the JavaScript
  4. In the JavaScript Editor dialog, enter your code. In the example below, a simple routine is created that opens an alert dialog box each time the file opens The code used is:

    var msg = "Created in Nitro PDF Pro";app.alert(msg);
  5. Click OK
    If your script was written properly, a dialog box should display each time the file is opened.

 

Last updated: July 30, 2026