Previous Next
This property puts the Acrobat viewer in fullscreen mode vs. regular viewing mode.
Example:
// on mouse up, set to fullscreen mode
app.fullscreen = true;
In the above example, the Adobe Acrobat viewer is set to fullscreen mode when app.fullscreen
is set to true. If app.fullscreen was false then default viewing mode would be set. The default
viewing mode is defined as the original mode the Acrobat application was in before full screen
mode was initiated.
language
Type: String Access: R
This property defines the language of the running Acrobat Viewer. It returns the following
strings:
String Language, Country
DEU German, Germany
ENU English, The United States of America
ESP Spanish, Spain
FRA French, France
ITA Italian, Italy
JPN Japanese, Japan
NLD Dutch, The Netherlands
SVE Swedish, Sweden
numPlugIns 4.0
Type: Number Access: R
This property indicates the number of plug-ins that have been loaded by Acrobat. See also the
getNthPlugInName method.
openInPlace 4.0
Type: Number Access: R/W
This property determines whether cross-document links are opened in the same window or
opened in a new window.
Acrobat Forms - JavaScript Object Specification 11
platform
Type: String Access: R
This property returns the platform that the script is currently executing on. Valid values
include “WIN”, “MAC”, and “UNIX”.
toolbar
Type: Boolean Access: R/W
This property allows a script to show or hide both the horizontal and vertical Acrobat tool bars.
It does not hide the tool bar in external windows (i.e. in an Acrobat window within a Web
browser).
Example:
// Opened the document, now remove the toolbar.
app.toolbar = false;
toolbarHorizontal 4.0
Type: Boolean Access: R/W
This property allows a script to show or hide the Acrobat horizontal tool bar. It does not hide
the tool bar in external windows (i.e. in an Acrobat window within a Web browser).
toolbarVertical 4.0
Type: Boolean Access: R/W
This property allows a script to show or hide the Acrobat vertical tool bar. It does not hide the
tool bar in external windows (i.e. in an Acrobat window within a Web browser).
viewerType
Type: String Access: R
This property determines if the running Acrobat Viewer is the Reader vs. Exchange. Its value
is “Reader” or “Exchange” respectively.
viewerVersion 4.0
Type: Number Access: R
This property indicates the version number of the current viewer (i.e. Reader or Exchange).
Acrobat Forms - JavaScript Object Specification 12
App Object Methods
alert
Parameters: cMessage, [nIcon], [nType]
Returns: nButton
This method displays an alert dialog on the screen. The minimum required parameter is a string
containing the message to be displayed. Optionally, an icon type can be specified by using the
nIcon parameter. The following is a list of icons and their associated values:
Icon Value
Error (default) 0
Warning 1
Question 2
Status 3
Additionally, a button group type can be specified:
Button Group Value
OK (default) 0
OK, Cancel 1
Yes, No 2
Yes, No, Cancel 3
This method returns the type of the button that was pressed by the user:
Button Type Value
Error 0
OK 1
Cancel 2
No 3
Yes 4
beep
Parameters: [nType]
Returns: none
Acrobat Forms - JavaScript Object Specification 13
This method causes the system to play a sound. The various sounds and the values used are as
follows:
Message Type Value
Error (default) 0
Warning 1
Question 2
Status 3
Default 4
On Apple Macintosh and UNIX systems the beep type is ignored.
execMenuItem 4.0
Parameters: cMenuItem
Returns: nothing
This method executes the specified menu item. To find out the exact menu item name, see the
Acrobat Viewer Plug-in API On-line Reference under § Lists: Menu item names. The menu
item name is case sensitive and has to exactly match strings in the list.
Example:
/* This example executes File->Open menu item. It will display a dialog to the
user asking for the file to be opened. */
app.execMenuItem("Open");
Note: For security reasons, we will not allow the script to execute the SaveAs and
Close menu items. If either of those two menu items is passed as cMenuItem,
this function will do nothing.
getNthPlugInName 4.0
Parameters: nIndex
Returns: cName
This method returns the name of the Nth plug-in that has been loaded by the viewer. See also
the numPlugIns property.
Acrobat Forms - JavaScript Object Specification 14
goBack
Parameters: None
Returns: nothing
Use this function to go to the previous view on the view stack. This is equivalent to pressing
the go back button on the Acrobat tool bar.
goForward
Parameters: None
Returns: nothing
Use this function to go to the next view on the view stack. This is equivalent to pressing the go
forward button on the Acrobat tool bar.
hideMenuItem 4.0
Parameters: cName
Returns: nothing
This method only works in the Config.js Plug-in folder level script. It allows a forms integrator
to customize the look of the Acrobat viewer by removing the menu item specified by cName.
Language independent names for toolbar buttons can be obtained from the Acrobat Viewer
Plug-In API On-line Reference (Technical Note #5168). See Other useful documents for more
details.
hideToolbarButton 4.0
Parameters: cName
Returns: nothing
This method only works in the Config.js Plug-in folder level script. It allows a forms integrator
to customize the look of the Acrobat viewer by removing the toolbar button specified by
cName. Language independent names for toolbar buttons can be obtained from the Acrobat
Viewer Plug-In API On-line Reference (Technical Note #5168). See Other useful documents for
more details.
mailMsg 4.0
Parameters: bUI, cTo, [cCc], [cBcc], [cSubject], [cMsgBody]
Returns: nothing
This method sends out an e-mail message with or without user interaction depending on the
value of bUI. If it is set to true then the rest parameters are used to seed the compose new
message window that is displayed to the user.
Acrobat Forms - JavaScript Object Specification 15
If bUI is set to false, the cTo parameter is required and others are optional. You must use a
semicolon “;” to separate multiple recipients in cTo, cCc, cBcc parameters. The length limit for
cSubject and cMsgBody is 64k bytes.
Example:
/* This will pop up the compose new message window */
app.mailMsg(true);
/* This will send out the mail to fun1@fun.com and fun2@fun.com */
app.mailMsg(false, "fun1@fun.com; fun2@fun.com ", "", "", "This is the subject",
"This is the body of the mail.");
Note: This is a Windows-only feature. In addition, the client machine must have its
default mail program configured to be MAPI enabled in order to use this
method.
response
Parameters: cQuestion [cTitle], [cOldValue]
Returns: cResponse or null on cancel
This method displays a dialog box containing a question and an entry field for the user to reply
to the question. Optionally, the dialog may have a title or a default value for the answer to the
question. The return value is a string containing the user’s response. If the user presses the
cancel button on the dialog the response is the null object.
Acrobat Forms - JavaScript Object Specification 16
Color Arrays
A color is represented in JavaScript as an array containing 1, 2, 4, or 5 elements corresponding
to a transparent, gray, RGB, or CMYK color space, respectively. The first element in the array
is a string denoting the color space type. The subsequent elements are numbers that range
between zero and one inclusive. The following table illustrates this:
Color Space String # of Additional
Elements
Transparent “T” 0
Gray “G” 1
RGB “RGB” 3
CMYK “CMYK” 4
For example, the color red can be represented as [“RGB” 1 0 0].
Invalid strings or insufficient elements in a color array cause the color to be interpreted as the
color black.
A transparent color space indicates a complete absence of color and will allow those portions
of the document underlying the current field to show through.
Colors in the gray color space are represented by a single value—the intensity of achromatic
light. In this color space, 0 is black, 1 is white, and intermediate values represent shades of
gray (i.e. “.5”, “.7” etc.).
Colors in the RGB color space are represented by three values: the intensity of the red, green,
and blue components in the output. RGB is commonly used for video displays because they are
generally based on red, green, and blue phosphors.
Colors in the CMYK color space are represented by four values. These values are the amounts
of the cyan, magenta, yellow, and black components in the output. This color space is
commonly used for color printers, where they are the colors of the inks traditionally used in
four-color printing. Only cyan, magenta, and yellow are necessary, but black is generally used
in printing because black ink produces a better black than a mixture of cyan, magenta, and
yellow inks, and because black ink is less expensive than the other inks.
Color Object
The color object is a convenience static object that defines the basic colors. These colors are
accessed in JavaScripts via the color object. Use this object whenever you want to set a
property or call a method that require a color array. The color object is defined in AForm.js.
Acrobat Forms - JavaScript Object Specification 17
Color Properties
The color object defines the following colors and there associated keywords:
Color Object Keyword Version
Transparent color.transparent
Black color.black
White color.white
Red color.red
Green color.green
Blue color.blue
Cyan color.cyan
Magenta color.magenta
Yellow color.yellow
Dark Gray color.dkGray
4.0
Gray color.gray
4.0
Light Gray color.ltGray
4.0
Example:
// This example sets the text color of the field to red
// if the value of the field is negative, else it sets it
// to black.
var f = event.target; /* field that the event occurs at */
if (event.value < 0)
f.textColor = color.red;
else
f.textColor = color.black;
Acrobat Forms - JavaScript Object Specification 18
Console Object
The Console object is a static object to access the JavaScript console for displaying debug
messages. It functions only within Acrobat Exchange.
Console Methods
show
Parameters: none
Returns: none
This method shows the console window.
hide
Parameters: none
Returns: none
This method closes the console window.
println
Parameters: cMessage
Returns: none
This method prints the string value of cMessage to the console window with an accompanying
carriage return.
Example:
// This example prints the value of a field to the console window
var f = event.target;
console.println("Field value = " + f.value);
clear
Parameters: none
Returns: nothing
This method clears the console windows buffer of any output.
Acrobat Forms - JavaScript Object Specification 19
Doc Object
The JavaScript Doc object provides the interfaces between a PDF document open in the viewer
and the JavaScript interpreter. It provides methods and properties of the PDF document.
Doc Access from JavaScript
Accessing the Doc object from JavaScript can be done either through the this Object, which
usually points to the Doc object of the underlying document. The target event property points
to the field that initiated the event for all mouse, calculate, validate, and format events. For all
other events, it directly points to the Doc object. The examples below illustrates the use of the
Event object to access the Doc object of the underlying document.
// In Mouse, calculate, validate, format events
var doc = event.target.doc;
// In all other events
var doc = event.target;
Doc Object Properties
author
Type: String Access: R/W
This property defines the author of the document.
this.author = "Robert Frost";
calculate 4.0
Type: Boolean Access: R/W
If this property is set to true, it will allow calculations to be performed for this document. If
set to false, this property prevents all calculations from happening for this document. Its
default value is true. This property supersedes the application level calculate property whose
use is now discouraged.
creator
Type: String Access: R
This property defines the creator of the document (e.g. “Adobe FrameMaker”, “Adobe
PageMaker”, etc.).
Acrobat Forms - JavaScript Object Specification 20
Previous Next