3
Acrobat JavaScript Contexts
Introduction to Acrobat JavaScript Contexts
Introduction to Acrobat JavaScript Contexts
Acrobat JavaScripts can be applied at a variety of levels:
●
●
●
●
folder
level
document
level
field
level
batch
level.
Each of these levels represents a context in which processing occurs, which has
implications about when the scripts are loaded and their accessibility inside and outside
documents.
In addition, the placement of a JavaScript at a given level determines its reusability. Folder
level scripts are available within all documents, document level scripts are available to all
form fields within a given document, field level scripts are only visible to the form fields
with which they are associated.
N
OTE
:
For instructions on how to disallow changes to scripts or hide scripts, see
How can I
How can I hide scripts
Folder Level JavaScripts
Folder level JavaScripts contain variables and functions that may be generally useful to
Acrobat, and are visible from all documents. There are two kinds of folder level scripts:
App
and
User.
For example, if you would like to add specialized menus and menu items to be
available to all documents opened in Acrobat, you may create and store the scripts for
these in folder level JavaScripts.
Folder level JavaScripts are placed in separate files that have the ".js" extension. App
folder level scripts are stored in the Acrobat application’s
JavaScripts
folder, and User
folder level scripts are stored in the user’s
JavaScripts
folder. These scripts are loaded
when Acrobat starts execution, and are associated with the
event
object’s
Application
Initialization
(
App/Init
) event.
When Acrobat is installed on your machine, it provides you with several standard folder
level JavaScript files, including
Aform.js,
,
Annots.js
, and
ADBC.js.
In addition, your
User
folder may also contain
glob.js
, which is programmatically generated and contains
cross-session application preferences set using the
global
object’s
setPersistent()
method, and
Config.js,
which is used to customize the look of the viewer by adjusting its
toolbar buttons and menu items. For example,
app.addMenuItem()
calls would be
locaed in
Config.js.
To create folder level JavaScripts, use an external editor running in parallel to Acrobat. Note
that the external editor cannot be invoked from Acrobat.
64
Acrobat JavaScript Scripting Guide