The information in this document is furnished for informational use only, is subject t change
without notice, and should not be construed a s a commitment by Adobe Systems Incorporated.
Adobe Syst ems Incorporated assumes no responsibility or liability for any err ors or inaccuracies that may appear in this document. The software described in this document is f urnished
under licens e and may only be used or copied in accordance with the terms of such license.
Adobe, the Adobe logo, Acr obat, Acrobat Capture, Acrobat Exchange, and Distiller are trademarks of Adobe Syste ms Incorporated. Microsoft and Windows are registered trademarks and
ActiveX is a t rademark of Microsoft in the U.S. and other countries. Macintosh is a trademark
of Apple Computer, Inc. registered in the U.S. and other countries. P owerPC is a trademark of
International Business Machines Corporation. UNIX is a registered trademark in the U.S. and
other countr ies, licensed exclusively through X/Open Co. Ltd. All other pr oducts or name
brands a re trademarks of their respective holders.
JavaScript, the scripting language developed by Netscape C ommunications, enables you to
easily create interactive We b pages .
JavaScript v1.2 comes with six predef ined classes: Boolean, Number, Date, Math, String,and
Array . As part of the integration with Adobe® Acrobat® Forms, we have defined additional
classes and objects to allow acces s to portions of the PDF file.
This document describ es these classes, as wel l as details the load and e xecution of JavaScripts
in the Adobe Acrobat environment. Of particular note is the Field Object section which handles
all pr ocessing of Acrobat Form fields including their formatting, calculation, and validation.
The intended audience of this document is assumed to be f amiliar with Adobe Acrobat, the
Acrobat Forms plug-in a nd the Adobe Ac robat plug-in API.
Other useful documents
For more information on JavaScript, please see Netscape’s JavaScript Refere nce Manual for
details on J avaScript objects and on language syntax.
Portable Document Format Reference Manual, v ersion 1.2 or later, describes the PDF
representation of a form and its fields. Appendix H , describes the Forms Data Format, which is
one of the formats of da ta exported f rom an Ac robat form. This document is available with the
Adobe A crobat Plug-ins SDK CD-ROM or on the Adobe Web site http://www.adobe.com/
supportservice/devrelations/PDFS/TN/PDFSPEC.PDF.
Technical Note #5166, Acrobat Viewer plug-in API Overview . Gives an overview of the objec ts
and methods provided by the Acrobat viewers’ plug-in API. This document is available with
the Adobe Acr obat Plug-ins SDK CD-ROM or on the Adobe Web site http://beta1.adobe.com/
ada/acrosdk/DOCS/VWRPIOVR. PDF.
Technical Note #5167, Acrobat Viewer plug-in API Development. Tells how to develop
Acrobat viewer plug-ins on the various platforms available. This document is available with
the Adobe Acr obat Plug-ins SDK CD-ROM or on the Adobe Web site http://beta1.adobe.com/
ada/acrosdk/DOCS/VWRP IDEV.PDF
Technical Note #5168, Acrobat Viewer plug- in A PI On-Line Refer ence. Describes in detail the
objects and methods provided by the Acrobat viewer’s plug-in API. This document is a vailable
Acrobat Forms - JavaScript Object Specification
7
with the Adobe Acrobat Plug-ins SDK CD-ROM or on the Adobe Web site http://
beta1.adobe.com/ada/acrosdk/DOCS/VWRPIREF.PDF.
Document Conventions
As this document pertains to Acrobat Forms version 3.5 and greater, there exists s ome
compatibility issues with older versions of the software. If a property, method, or object is
marked with asymbol, then it is available only in ver sions of the Acrobat Forms sof tware
#.#
greater than or equal to #.#. Before accessing this object, proper ty, or method, the script should
check that the application version is greater than or equal to #.# if backwards compatibility is
desired.
Example:
if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0) {
// Perform version specific operations.
}
As the JavaScr ipt extensions to Acrobat Forms have evolved, some properties or methods have
been superseded by other, mor e flexible or appropriate properties or methods. The use of these
older m ethods are discouraged and marked by Mr. Unhappy.
Acrobat Forms - JavaScript Object Specification
8
What’s New for 4.0
ObjectPropertiesMethods
App Object
Colo r O b j e ct
Doc Objectcalculate, delay,
Field Object
Util Object
formsVersion,
numPlugIns
openInPlace
toolbarHori z ontal
toolbarV ertical
viewerVersion
Note:Items shown in italics are not new to this release but they have been
modified or added t o.
New sections of the documentation for 4. 0:
New SectionDescription
Working With The
Date Object
Acrobat Forms
and Security
Working with
Signature Fields
Describes the proper methods for formatting
and parsing dates and performing date
arithmetic.
Shows how to properly define security settings
in a form so that it cannot be tampered with.
Details the proper usage of scripts when
signing documents includ ing inverse
operations upon form reset
Acrobat Forms - JavaScript Object Specification
9
Acrobat Forms JavaScript Object Model
Acrobat Forms de fines an object model on top of JavaScript 1.2. These objects are only
defined within the Adobe Acr obat realm and are specific to Acrobat Forms. They basically
mirror the Acrobat Forms components and give the forms developer a way to access these
components programmatically in or der to query and change their properties. In addition to
defining forms specific objects, ther e are additional generic objects that allows the developer
to ac cess the underlying document and perform certain actions on it.
App Object
The App object is a static JavaScript object that defines a number of Acrobat specific functions
plus a variety of utility routines and convenience functions.
App Object Properties
calculate
Type: BooleanAccess: R/W
If this property is s et to true, it will allow calculations to be performed. If set to false,this
property prevents all calculations in all documents from happening. Its default value is true.
See a lso the document calculate property which supersedes this property in later versions.
formsVersion
Type: NumberAccess: R
This property indicates the version number of the forms software running inside the view er.
Use this method to determine whethe r objects , properties, or methods in newer ver sions of the
software are available if you wish to maintain backwards compatibility in your scr ipts. See
Document Conventions for more details.
Example:
if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.5) {
// Perform version specific operations here.
}
4.0
fullscreen
Type: BooleanAccess: R/W
Acrobat Forms - JavaScript Object Specification
10
This pr operty 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 tr u e .Ifapp.fullscreen was false then def ault viewing mode would be set. The default
viewing mode is defined as the original mode the Acrobat application was in before full s creen
mode wa s initiated.
language
Type: StringAccess: R
This property defines the language of the running Acrobat Viewer. It returns the following
strings:
StringLanguage, Country
DEUGerman, Germany
ENUEnglish, The United States of Am erica
ESPSpanish, Spain
FRAFrench, France
ITAItalian, Italy
JPNJapanese, Japan
NLDDutch, The Netherlands
SVESwedish, Sweden
numPlugIns
4.0
Type: NumberAccess: R
This property indicates the number of plug-ins that have been loa ded by Acr obat. See als o the
getNthPlugInName method.
openInPlace
4.0
Type: NumberAccess: 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: StringAccess: R
This propert y returns the pla tform that the script is currently executing on. Valid values
include “WIN”, “MAC”, and “UNIX ”.
toolbar
Type: BooleanAccess: R/W
This pr operty allows a script to show or hide both the horizontal and ve rtical 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
Type: BooleanAccess: R/W
This pr operty allows a script to show or hide the Acr obat horizontal tool bar. It does not hide
the tool bar i n external windows (i.e. in an Acrobat window within a Web browser).
toolbarVertical
Type: BooleanAccess: R/W
This property allows a script to show or hide the Ac robat ve rtical tool bar. It does not hide the
tool bar in external windows ( i.e. in an Acrobat window within a Web browser).
viewerType
Type: StringAccess: R
This property determines if the r unning Acrobat Viewer is the Rea der vs. Exchange. Its value
is “Reader” or “Exchange” r espectivel y.
4.0
4.0
viewerVersion
Type: NumberAccess: R
This pr operty indicates the version number of the current viewer (i.e. Reader or Exchange) .
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 t he
nIcon par ameter. The following is a list of icons and their associated values:
IconValue
Error (default)0
Warning1
Question2
Status3
Additionally, a button group type can be specified:
Button GroupValue
OK (default)0
OK, Cancel1
Yes, No2
Yes, No, Cancel3
This method returns the type of the button that was pressed by the user:
Button TypeValue
Error0
OK1
Cancel2
No3
Yes4
beep
Parameters: [nType]
Return s: n one
Acrobat Forms - JavaScript Object Specification
13
This method causes the system to play a s ound. The various sounds and the values used are as
follows:
On Apple Ma cintosh a nd UNIX systems the beep type is ignored.
execMenuItem
4.0
Parameters: cMenuItem
Returns: nothing
This method executes the spe cified 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 s ecurity reasons, we will not allow the script to execute t he 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 bee n loaded by the view er. 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 stac k. This is equivalent to pressing
the go back button on the Acrobat tool bar.
goForward
Parameters: None
Returns: nothing
Use t his function to go to the next view on the view stack. This is equivalent to pressing the go
forward button on the Acrobat tool ba r.
hideMenuItem
Parameters: cName
Returns: nothing
This method only works in the Config.js Plug-i n fo lder l evel script. It allows a forms integrator
to customize the look of the Acrobat viewer by removing the m enu item specified by cName .
Language independent names for toolbar buttons can be obtaine d fr om the Acrobat ViewerPlug-In API On-line Reference (Technical Note #5168).SeeO ther use ful docum ents for more
details.
hideTo olbarButt on
Parameters: cName
Returns: nothing
This method only works in the Config.js Plug-i n fo lder l evel script. It allows a forms integrator
to customize the look of the Acrobat viewer by removing the toolbar button specified by
cName. Language independe nt names for toolbar buttons can be obtained from the Acrobat
Viewer Plug-In API On-line Reference (Technical Note #5168).SeeOther use ful doc um ent s for
This method sends out an e-mail message with or without user interaction depending on the
value of bUI. I f it is set to true then the rest parame ters are used to seed the compose new
message window that is displayed to the user.
Acrobat Forms - JavaScript Object Specification
4.0
15
If bUI is set to false, the cTo para meter 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 de fault value for the answer to the
question. The return va lue is a string c ontaining the user’s response. I f the user presses the
cancel button on the dialog the r esponse 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 transpar ent, gray, RGB, or CMYK color space, respectively. The first element in the arr ay
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 SpaceString#of Additional
Elements
Transparent“T”0
Gray“G”1
RGB“RGB”3
CMYK“CMYK”4
For example, the color red can be represent ed as [“RGB” 1 0 0].
Invalid strings or ins ufficient elements in a color array cause the color to be interpreted as the
color black.
A transparent color spa ce 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 colo r space are represented by three values: the intens ity of the r ed, green,
and blue components in the output. RGB is commonly used f or video displays bec ause they are
generally bas ed on red, green, and blue phosphors.
Colors in the CMYK color spa ce are represented by four values. These va lues 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 us ed in
four-color printing. Only cya n, magenta, and yellow are necessary, but black is generally us ed
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 colo r object is a convenience static object that defines the basic colors . These colors are
accessed in JavaScr ipts via the color obj ect. Use t his objec t whene ver you want to set a
property or call a method tha t require a color array. T he color object is defined in AForm.js.
Acrobat Forms - JavaScript Object Specification
17
Color Properties
The color object defines the following color s and there associated keywords:
// 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)
else
Dark Graycolor.dkGray
Graycolor.gray
Light Graycolor.ltGray
f.textColor = color.red;
f.textColor = color.black;
4.0
4.0
4.0
Acrobat Forms - JavaScript Object Specification
18
Console Object
The Console objec t is a static object to acces s the JavaScript console for displaying debug
messages. I t functions only within Acrobat Exchange.
Console Methods
show
Parameters: none
Return s: n one
This method shows the console window.
hide
Parameters: none
Return s: n one
This method closes the console window.
println
Parameters: cMessage
Return s: n one
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 cons ole windows buffer of any output.
Acrobat Forms - JavaScript Object Specification
19
Doc Object
The JavaScript Doc objec t provides the interfaces between a PDF document open in the viewer
and the J avaScript interpreter. It provides methods and properties of the PDF document.
Doc Access from JavaScript
Accessing the Doc object f rom 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: StringAccess: R/W
This property defines the author of the document.
this.author = "Robert Frost";
calculate
Type: BooleanAccess: 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: StringAccess: R
4.0
This property defines the creator of the document (e.g. “Adobe FrameMaker”,“Adobe
PageMaker”, etc.).
Acrobat Forms - JavaScript Object Specification
20
Loading...
+ 44 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.