
Adobe Acrobat SDK
Working with Bookmarks
Developing Plug-ins and Applications
Defining bookmark actions 115
Defining bookmark actions
After you create a new bookmark, you must define an action that occurs when a user clicks on the
bookmark. Otherwise, nothing occurs when a user clicks on the bookmark.
To create an action for a bookmark, you must create a
PDAction
object that represents the action that
occurs when a user clicks on a bookmark. Once you create a
PDAction
object, you can assign it to a
bookmark. For information, see
“Assigning an action to a bookmark” on page 116
.
As specified earlier in this chapter, a typical bookmark action is to move to another location in the current
document. To illustrate how to create a bookmark action, this section defines a bookmark action that
displays a specific page in a PDF document when a user clicks the bookmark.
To define a bookmark action that generates a specific view of a PDF document, you create a
PDAction
object by invoking the
PDActionNewFromDest
method. This method creates a new action that directs
the user to the specified destination view and requires the following arguments:
●
A
PDDoc
that represents the PDF document for which the action is created.
●
A
PDViewDestination
object that represents a specific view in the PDF document. For information,
see
“Creating a PDViewDestination object” on page 115
.
●
A
PDDoc
that represents the destination document. This object is the same object that is specified as
the first parameter.
The
PDActionNewFromDest
method returns a
PDAction
method.
Creating a PDViewDestination object
You must create a
PDViewDestination
object in order to invoke the
PDActionNewFromDest
method.
To create a
PDViewDestination
object, invoke the
AVPageViewToViewDest
method and pass the
following arguments:
●
An
AVPageView
object that represents the page view from which the destination is created. For
information about creating this object, see
“Creating a AVPageView object” on page 116
.
●
An
ASAtom
object that specifies the fit type of the view destination (see the table that follows this list).
●
A
PDDoc
object that represents the PDF document for which the view is established.
The
AVPageViewToViewDest
method returns a
PDViewDestination
object. The following table
specifies the fit type values that you pass to the
AVPageViewToViewDest
method as the second
argument.
Value
Description
XYZ
Destination specified as upper-left corner point and a zoom factor.
Fit
Fits the page into the window, corresponding to the Acrobat viewer’s FitPage menu item.
FitH
Fits the width of the page into the window, corresponding to the Acrobat viewer’s Fit Width
menu item.
FitV
Fits the height of the page into a window.
FitR
Fits the rectangle specified by its upper-left and lower-right corner points into the window.
FitB
Fits the rectangle containing all visible elements on the page (known as the bounding box) into
the window (corresponds to the Acrobat viewer’s Fit Visible menu item).