10
Modifying the User Interface
Adding Navigation to PDF Documents
Removing Web Links
To remove Web links that were authored in Acrobat, invoke the
doc
object’s
removeWeblinks
method. It accepts two optional parameters:
nStart
and
nEnd
represent the beginning and end of an inclusive range of page numbers. The following
examples illustrate how to remove Web links from different page ranges in the document:
// remove the Web links from pages 2 through 5:
this.removeWeblinks({nStart: 2, nEnd: 5});
// remove the Web links from page 7
this.removeWeblinks({nStart: 7});
// remove the Web links from pages 0 through 7:
this.removeWeblinks({nEnd: 7});
// remove all the Web links in the document:
this.removeWeblinks();
Using Destinations
To go to a named destination within a document, embed a JavaScript in the call to the
link
object’s
setAction
method. The script contains a call to the
doc
object’s
gotoNamedDest
method.
The following example goes to the destination named as
Chapter5
in the current
document when
myLink
is clicked:
myLink.setAction("this.gotoNamedDest('Chapter5');");
Using Actions for Special Effects
Thumbnails, bookmarks, links, and other objects have actions associated with them, and
you may use Acrobat JavaScript to customize their behavior. For example, you can use
them to display messages, jump to destinations in the same document or any other, open
attachments, open Web pages, execute menu commands, or perform a variety of other
tasks.
Adding Actions
As you learned earlier, you may associate a thumbnail with a
Page Open
event, and
associate bookmarks and links with
Mouse Up
events.
You may use Acrobat JavaScript to customize the actions associated with a thumbnail by
invoking the
doc
object’s
setPageAction
method. To customize the actions associated
with bookmarks and links, create a string containing Acrobat JavaScript code and pass it to
the object’s
setAction
method. In the examples shown below, a greeting is displayed
when a thumbnail, bookmark, and link are clicked:
178
Acrobat JavaScript Scripting Guide