Acrobat JavaScript Contexts
Document Level JavaScripts
3
Document Level JavaScripts
Document level JavaScripts are function and variable definitions that are generally useful
to a given document, but are not applicable outside the document.
To create or access document level JavaScripts in Acrobat, select
Advanced > JavaScript >
Document JavaScripts…,
which enables you to add, modify, or delete document level
scripts. Document level scripts are executed after the document has opened, and are stored
within the PDF document.
Field Level JavaScripts
You can associate a JavaScript with any component within a document. In the case of
dynamic XML forms, such scripts are only visible to that component and execute as actions
or events. For example, you may associate an action page open or page close events, as
well as a
MouseUp
event for a bookmark, page, or form field. Field level scripts are
executed as the events occur, and are usually applied to validate, format, or calculate form
field values. Like document level scripts, field level scripts are stored within the PDF
document.
There are several ways to create or edit field level JavaScripts. The most straightforward
manner is to right-click the form field, select
Properties
context menu item and choose the
Actions
tab, as shown above in
Figure 2.6.
Additionally, you may select
Advanced >
JavaScripts > Edit all JavaScripts ....
Batch Level JavaScripts
A batch level JavaScript is a script that can be applied to a collection of documents, and
operates at the application level. For example, you may define a batch script to print a
series of documents or apply security restrictions to them.
To create or edit a batch level JavaScript in Acrobat, select
Advanced > Batch
Processing....
Acrobat JavaScript Scripting Guide
65