Previous Next
creationDate
Type: Date Access: R
This property defines the documents creation date.
delay 4.0
Type: Boolean Access: R/W
This property delays the redrawing of any appearance changes to every field in the document.
It is generally used to buffer a series of changes to fields before requesting that the fields
regenerate their appearance. Setting the property to true forces all changes to be queued until
delay is reset to false. Once set to false then all the fields on the page are re-drawn. See also
the field level delay property.
dirty
Type: Boolean Access: R/W
This property identifies whether the document has been dirtied as the result of a changes to the
document (and therefore needs to be saved). It is useful to reset the dirty flag in a document
when performing changes that do not warrant saving, for example, updating a status field in the
document.
var f = this.getField("Status");
var b = this.dirty;
f.value = "Press the reset button to clear the form.";
this.dirty = b;
external 4.0
Type: Boolean Access: R
This property indicates whether the current document is being viewed in the Acrobat
application or in an external window (such as a web browser).
filesize
Type: Integer Access: R
This property determines the file size of the document in bytes.
Acrobat Forms - JavaScript Object Specification 21
keywords
Type: String Access: R/W
This property specifies the document’s keywords in the Adobe Acrobat File->Document Info-
>General dialog box.
modDate
Type: Date Access: R
This property contains the date the document was last modified.
numFields 4.0
Type: Integer Access: R
This property returns the total number of fields in the document. See also the getNthFieldName
method.
numPages
Type: Integer Access: R
This property contains the number of pages in the document.
numTemplates
Type: Integer Access: R
This property returns the number of templates in the document (see also getNthTemplate and
spawnPageFromTemplate methods).
path
Type: String Access: R
This property defines the device independent path of the document, for example /Acrobat3/
Exchange/doc.pdf
pageNum
Type: Integer Access: R/W
Acrobat Forms - JavaScript Object Specification 22
Use this property to get or set a page of the document. When setting the pageNum to a specific
page, remember that the values are “0” based.
// This example will go to the first page of the document.
this.pageNum = 0 ;
Or pageNum can be used to advance “n” pages in the document:
// This example will advance the document to the next page
this.pageNum++;
producer
Type: String Access: R
This property contains producer of the document (e.g. “Acrobat Distiller”, “PDFWriter”, etc.).
subject
Type: String Access: R/W
This property defines the document’s subject.
title
Type: String Access: R/W
This property specifies the document’s title
zoom
Type: Integer Access: R/W
Use this property it to get or set the current page zoom level. The values allowed are 12% and
800% specified as an integer.
Example:
// This example will zoom in to twice the current zoom level.
this.zoom *= 2;
// This now sets the zoom to 200%
this.zoom = 200;
Acrobat Forms - JavaScript Object Specification 23
zoomType
Type: String Access: R/W
This property specifies the current zoom type of the document. Valid zoom types are: none, fit
page, fit width, fit height, and fit visible width. A convenience zoomType object that defines all
the valid zoom types is provided for use from JavaScript. It provides the following zoom types:
Zoom Type Keyword
NoVary zoomtype.none
FitPage zoomtype.fitP
FitWidth zoomtype.fitW
FitHeight zoomtype.fitH
FitVisibleWidth zoomtype.fitV
Preferred zoomtype.pref
Example:
// This example sets the zoom type of the document to fit the width.
this.zoomType = zoomtype.fitW;
Doc Object Methods
calculateNow
Parameters: none
Returns: nothing
Use this function to force computation of all calculation fields in the current document.
exportAsFDF 4.0
Parameters: [bAllFields], [bNoPassword], [aFields], [bFlags]
Returns: nothing
Use this method to export an FDF file to the local hard drive. Upon invocation, a dialog will be
shown to let the user select the file to export to.
The optional bAllFields parameter indicates, if true, that all fields are exported, including those
that have no value, and if false (the default) to exclude those that currently have no value.
The optional bNoPassword parameter indicates, if true (the default), not to include in the
exported FDF text fields that have the “password” flag set.
Acrobat Forms - JavaScript Object Specification 24
The optional aFields parameter is the array of field names to submit or a string containing a
single field name. If this parameter is present then only the fields indicated are exported,
except those excluded by parameter bEmpty or bNoPassword. If this parameter is omitted or is
null then all fields in the form are exported (again subject to the restrictions of bEmpty).
You can include non-terminal fields in the array or the string passed as a parameter: this is a
simple shortcut for having a whole subtree exported.
Example:
/* Export the entire form (including empty fields) with flags. */
this.exportAsFDF(true, true, null, true);
/* Export the name subtree with no flags. */
this.exportAsFDF(false, true, “name”);
The example above illustrates a shortcut to exporting a whole subtree. Passing “name” as part
of the aFields parameter, exports “name.title”, “name.first”, “name.middle” and “name.last”,
etc.
The optional aFlags parameter indicates, if true, that field flags should be included in the
exported FDF. The default is false.
This method does not work in the Acrobat Reader.
getField
Parameters: cName
Returns: object
Use this function to map a field object in the PDF document to a JavaScript variable. The
cName parameter is the name of the field of interest. This function returns a Field JavaScript
object representing the form field in the PDF document.
getNthFieldName 4.0
Parameters: nIndex
Returns: cName
Use this function to obtain the nth field name in the document (see the numFields property).
Example:
// Enumerate through all of the fields in the document.
for (var i = 0; i < this.numFields; i++) {
console.println("Field[" + i + "] = " + this.getNthFieldName(i));
}
Acrobat Forms - JavaScript Object Specification 25
getNthTemplate
Parameters: nWhich
Returns: cName
Use this function to retrieve the name of a template within in the document. (See also the
numTemplates property and spawnPageFromTemplate method.)
getURL 4.0
Parameters: cURL, [bAppend]
Returns: nothing
This method retrieves the specified URL over the internet using a GET. If the current
document is being viewed inside the browser or Acrobat Web Capture is not available, it uses
the Weblink plug-in to retrieve the requested URL. If bAppend is true (the default) and Acrobat
Web Capture is available, the resulting pages are appended to the current document.
gotoNamedDest
Parameters: cName
Returns: nothing
Use this method to go to a named destination within the PDF document. For more details on
named destinations and how to create them, see the PDF Reference Manual Version 1.3
importAnFDF 4.0
Parameters: [cFile]
Returns: nothing
This method imports the specified FDF file. The cFile parameter specifies the device-
independent pathname to the FDF file. See Section 7.4 of the PDF Reference Manual for a
description of the device-independent pathname format (it should look like the value of the /F
key in an FDF exported via the exportAsFDF method or via the “File->Export->Form Data”
menu item). The pathname may be relative to the location of the current document. If the
parameter is omitted a dialog will be shown to let the user select the file. This method does not
work in the Acrobat Reader.
mailDoc 4.0
Parameters: bUI, cTo, [cCc], [cBcc], [cSubject], [cMsgBody]
Returns: nothing
This method saves the current PDF document and mails it as an attachment to all recipients
with or without user interaction depending on the value of bUI. If it is set to true then the rest
Acrobat Forms - JavaScript Object Specification 26
of the parameters are used to seed the compose new message window that is displayed to the
user.
If bUI is set to false, the cTo parameter is required and all 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 */
this.mailDoc(true);
/* This will send out the mail with the attached PDF file to fun1@fun.com and
fun2@fun.com */
this.mailDoc(false, "fun1@fun.com", "fun2@fun.com", "", "This is the subject",
"This is the body.");
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.
mailForm 4.0
Parameters: bUI, cTo, [cCc], [cBcc], [cSubject], [cMsgBody]
Returns: nothing
This method exports the form data and mails the resulting FDF file as an attachment to all
recipients, with or without user interaction depending on the value of bUI. If it is set to true
then the rest of the parameters are used to seed the compose new message window that is
displayed to the user.
If bUI is set to false, the cTo parameter is required and all 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 */
this.mailForm(true);
/* This will send out the mail with the attached FDF file to fun1@fun.com and
fun2@fun.com */
this.mailForm(false, "fun1@fun.com; fun2@fun.com", "", "", "This is the
subject", "This is the body of the mail.");
Acrobat Forms - JavaScript Object Specification 27
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.
print
Parameters: bInteractive, [nFirstPage], [nLastPage], [bSilent]
Returns: nothing
Use this function to print all or a specific number of pages of the document. If bInteractive is
true, Acrobat displays the standard print dialog and all other parameters are ignored. The
optional nFirstPage and nLastPage parameters specify the range of pages to print. If using
nFirstPage and nLastPage parameters bInteractive must be false. Set the optional bSilent flag
to true if you don’t want to display the cancel dialog box while the document is printing. The
default value for bSilent flag is false.
Example:
// This Example will print current page the document is on
this.print(false, this.pageNum, this.pageNum);
resetForm
Parameters: [aFields]
Returns: nothing
Use this method to reset the field values within a document. If the aFields parameter is
present, then only the fields indicated are reset. If not present or null then all fields in the form
are reset. You can include non-terminal fields in the array. Use this as a simple shortcut for
having a whole subtree reset. For example, if you pass “name” as part of the fields array then
“name.first”, “name.last”, etc. will be reset.
var fields = new Array(2);
fields[0] = "P1.OrderForm.Description";
fields[1] = "P1.OrderForm.Qty";
this.resetForm(fields);
scroll
Parameters: xOrigin, yOrigin
Returns: nothing
Acrobat Forms - JavaScript Object Specification 28
Use this function to scroll the current page to the location specified by xOrigin and yOrigin.
These coordinates must be defined in user space. Please refer to the PDF Reference Manual
Version 1.3 for more details on the user space coordinate system.
spawnPageFromTemplate
Parameters: cTemplate, [nPage], [bRename], [bInsert]
Returns: nothing
Use this method with a template name, such as the ones returned by getNthTemplate. The
optional parameter nPage, represents the page number (zero-based) into which the template
will be spawned. If that page already exists, then the template contents are appended to that
page. If nPage is omitted, a new page is created at the end of the document. The optional
parameter bRename, is a boolean that indicates whether fields should be renamed. The default
for bRename is true.
Example:
var n = this.numTemplates;
var cTempl;
for (i = 0; i < n; i++) {
cTempl = this.getNthTemplate(i);
this.spawnPageFromTemplate(cTempl);
}
4.0 Addition
If bInsert is specified then the template is inserted before the page specified by nPage as
opposed to being overlaid on top of that page. The default for bInsert is false.
submitForm
Parameters: cURL, [bFDF], [bEmpty], [aFields], [bGet]
Returns: nothing
Use this method to submit the form to a specific URL. The first parameter, cURL, is the URL
to submit to. This string must end in “#FDF” if the result from the submission is FDF and the
document is being viewed inside a browser window.
The optional bFDF parameter is a boolean that indicates to submit as FDF or HTML. If set to
true, the default, it submits the form data as FDF. If false, it submits it as HTML (URL
encoded).
The optional bEmpty parameter is a boolean that indicates, when true, that all fields are
submitted, including those that have no value and if false to exclude those that currently have
no value. The default for bEmpty is false.
Acrobat Forms - JavaScript Object Specification 29
The optional aFields parameter is the array of field names to submit or a string containing a
single field name. If this parameter is present then only the fields indicated are submitted,
except those excluded by parameter bEmpty. If this parameter is omitted or is null then all
fields in the Form are submitted (again subject to the restrictions of bEmpty).
You can include non-terminal fields in the array or the string passed as a parameter: this is a
simple shortcut for having a whole subtree submitted.
Example:
/* Submit the form to the server */
this.submitForm("http://myserver/cgi-bin/myscript.cgi#FDF");
/* Or */
this.submitForm("http://myserver/cgi-bin/myscript.cgi#FDF",
true, "name");
The example above illustrates a shortcut to submitting a whole subtree. Passing “name” as part
of the field parameter, submits “name.title”, “name.first”, “name.middle” and “name.last”.
4.0 Addition
The optional bGet parameter indicates, if true, that the submission uses the GET HTTP method
and if false (the default) a POST. GET is only allowed if using Acrobat Web Capture to submit
(the browser interface only supports POST) and only if the data is sent as HTML (i.e. bFDF
should be false).
Note: You need to be running inside a web browser or have the Acrobat Web
Capture plug-in installed, in order to call the submitForm method (unless
the URL uses the “mailto” scheme, in which case it will be honored even if
not running inside a web browser, as long as the SendMail plug-in is
present).
Note: Usage of the https protocol is supported for secure connections.
Acrobat Forms - JavaScript Object Specification 30
Previous Next