2
Acrobat JavaScript Tools
Using the Built-in Acrobat JavaScript Editor
Using the Built-in Acrobat JavaScript Editor
Like the Acrobat JavaScript Console, the built-in Acrobat JavaScript Editor can be used to
evaluate portions of JavaScript code. Select a line or block of code to be evaluated, and
press the
Enter
key on the numeric keypad or
Ctrl+Enter
on the regular keyboard.
In this case, the results of the JavaScript expressions or statements are displayed in the
Console window, so you will also need to open the Acrobat JavaScript Console to see them.
This is how you may keep the results separate from your Acrobat JavaScript code.
The Acrobat JavaScript Editor provides the same formatting options as those in the console
window. For details, see
Formatting Code.
Using an External Editor
If an external editor program has been specified as the default application for editing
JavaScripts in Acrobat, Acrobat generates a temporary file and opens it in the external
editor program. When editing a file in an external editor, note the following restrictions:
●
●
●
You must save the file in order for Acrobat to detect the changes.
Acrobat is inaccessible while the external editor is in use.
Acrobat JavaScript code cannot be evaluated within the external editor.
Additional Editor Capabilities
Acrobat supports some additional command line editor capabilities for Windows-based
applications, and provides support for two parameters in particular: the
file name
(
%f
) and
the
target line number
(
%n
). Parameters for Macintosh-based editors are not supported.
Note that Acrobat launches a new instance of the editor for each new editing session. Some
editors, if already running, load new files into the same session and may close the other
open files without saving them. Thus, it is important to remember to take one of the
following measures: save your changes before beginning a new editing session, close the
editor application before starting a new editing session, or adjust its default preferences so
that it always launches a new editor instance (this is the best course of action, if available).
If you are able to set the editor preferences to launch a new instance for each editing
session, and if the editor requires a command line parameter in order to invoke a new
editor instance, you may add that parameter to the editor command line specified in the
Edit > Preferences > JavaScript
dialog.
If your editor accepts a starting line number on the command line, Acrobat can start the
editor on a line containing a syntax error by inserting the line number as a command line
parameter (
%n
).
42
Acrobat JavaScript Scripting Guide