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


Download the 14-day free trialBuy online now


Writing document level scripts

Document level scripts are used to add functions from which other scripts can reuse routines throughout a PDF file. You can also use document level JavaScripts to invoke actions when a file opens.

To write a document level JavaScript:

  1. Open a PDF file and select Document > JavaScript > Document JavaScripts.
  2. Click Add in the JavaScript Functions window.
  3. Type a name for your function when prompted in the Set Document JavaScript dialog box and click OK.
  4. In the right pane, select all the default text and press Delete.
  5. Click in the right pane and type a JavaScript routine. In the example below, a simple routine is created that opens an alert dialog box each time the file opens in Nitro PDF Professional. The code used is:
  6. var msg = "Created in ARTS Nitro PDF Desktop"
    app.alert(msg)

  7. Click Close. If your script was written properly, a dialog box opens displaying the message.