10
Modifying the User Interface
Adding Navigation to PDF Documents
Acrobat JavaScript makes the
bookmarkRoot
object available as a property of the
doc
object. This root node contains a property called
children
, which is an array of
bookmark
objects. The
bookmark
object has the properties shown below in
Table 10.6,
and the methods shown below in
Table 10.7:
T
ABLE
10.6
Bookmark Properties
Property
Description
Returns the array of child objects for the current node
Specifies the color for the bookmark
The document object for the bookmark
The text string appearing in the navigational panel
Determines if children are shown
The parent bookmark
Font style
children
color
doc
name
open
parent
style
T
ABLE
10.7
Bookmark Methods
Method
Description
Creates a new child bookmark
Executes the
Mouse Up
action for the bookmark
Inserts a bookmark as a new child for this bookmark (this
may be used to move existing bookmarks)
Removes the bookmark and all its children
Sets a
Mouse Up
action for the bookmark
createChild
execute
insertChild
remove
setAction
Creating Bookmarks
To create a bookmark, it is necessary to navigate through the bookmark tree and identify
the parent of the new node. Begin by accessing the
bookmarkRoot
, which is a property
of the current document representing the top node in the bookmark tree:
var myRoot = this.bookmarkRoot;
Assume there are no bookmarks in the document. To create a new bookmark, invoke the
bookmarkRoot
object’s
createChild
method to which you may submit the following
parameters:
cName
(the name to appear in the navigational panel),
cExpr
(an optional
JavaScript to be executed when the bookmark is clicked), and
nIndex
(an optional zero-
based index into the
children
array).
172
Acrobat JavaScript Scripting Guide