Acrobat JavaScript Tools
Using the Acrobat JavaScript Console
2
Using the Acrobat JavaScript Console
The Acrobat JavaScript Console provides an interactive and convenient interface for testing
portions of JavaScript code and experimenting with object properties and methods.
Because of its interactive nature, the console behaves as an editor that permits the
execution of single lines or blocks of code.
There are two ways to activate the Acrobat JavaScript Console: either through an Acrobat
menu command or through the use of the static
console
object within Acrobat
JavaScript code. In either case, it appears as a component of the Acrobat JavaScript
Debugger, and the primary means of displaying values and results is through the
console.println()
method.
Opening the JavaScript Console
To open the Acrobat JavaScript console from within Acrobat:
1.
Open the debugger window using one of these methods:
– Select
Advanced > JavaScript > Debugger,
or
– Type
Ctrl-j
(Windows) or
Command-j
(Macintosh)
2.
Select either
Console
or
Script and Console
from the debugger’s
View
list.
To open and close the console from Acrobat JavaScript code, use
console.show()
and
console.hide()
, respectively.
Executing JavaScript
The Acrobat JavaScript Console allows you to evaluate single or multiple lines of code.
There are three ways to evaluate JavaScript code while using the interactive console:
●
To evaluate a portion of a line of code, highlight the portion and press either the
Enter
key on the numeric keypad or type
Ctrl+Enter
on the regular keyboard.
To evaluate a single line of code, make sure the cursor is positioned on that line and
press either the
Enter
key on the numeric keypad or type
Ctrl+Enter
on the regular
keyboard.
To evaluate multiple lines of code, highlight those lines and press either the
Enter
key
on the numeric keypad or type
Ctrl+Enter
on the regular keyboard.
●
●
In all cases, the result of the most recent single JavaScript statement executed is displayed
in the console.
Acrobat JavaScript Scripting Guide
31