public final class PdfBookmark extends Object
The PdfBookmark
class is used to create, delete, and
modify bookmarks. The class has methods to:
An object of this class is returned when addBookmark
method of PdfDocument
class is employed.
getFirstBookmark
method of PdfDocument
class
is used to retrieve the first bookmark of an existing document.
Modifier and Type | Class and Description |
---|---|
static class |
PdfBookmark.RemoteGoTo
This class represents a
destination
in an external PDF file.
|
Modifier and Type | Field and Description |
---|---|
static int |
BOLD
Constant for displaying titles of bookmarks in bold type.
|
static int |
FIT
Constant for adjusting magnification factor (zoom) of a page
just enough to fit the entire page within the width and height
of the viewer window.
|
static int |
FITB
Constant for adjusting magnification factor (zoom) of a page to
tightly fit entire height and width of its
bounding box
inside a window.
|
static int |
FITBH
Constant for positioning the top edge of the viewer window at a
specified distance from the top edge of a page and adjusting the
magnification factor (zoom) so as to tightly fit entire width
of the page's
bounding box
inside the window.
|
static int |
FITBV
Constant for positioning the left edge of the viewer window at a
specified distance from the left edge of a page and adjusting the
magnification factor (zoom) so as to tightly fit entire height
of the page's
bounding box
inside a window.
|
static int |
FITH
Constant for adjusting magnification factor (zoom) of a page to
tightly fit its entire width inside a window.
|
static int |
FITV
Constant for positioning the left edge of the viewer window at
a specified distance from the left edge of a page and adjusting
the magnification factor (zoom) so as to tightly fit its entire
height inside a window.
|
static int |
ITALIC
Constant for displaying title of bookmarks in italic style.
|
Modifier and Type | Method and Description |
---|---|
void |
addAction(PdfAction action)
Adds a specified document-level action.
|
void |
addActionGoto(int pageNo)
Adds to this bookmark a
go-to action
capable of changing the current view of the document to a
destination
page specified by
pageNo . |
void |
addActionGoto(int pageNo,
double left,
double top,
double zoom)
Adds to this bookmark a
go-to action
capable of changing the current view of the document to a
destination
specified by location (
left , top ),
page pageNo , and magnification factor
zoom . |
void |
addActionGoto(int pageNo,
double x,
double y,
double width,
double height)
Adds to this bookmark a go-to action capable of
changing the current view of the document to a specified
rectangular area on a specified page.
|
void |
addActionGoto(int pageNo,
double pos,
int fit)
Adds to this bookmark a
go-to action
capable of changing the current view of the document to a
destination
specified by
pos and fit on page
pageNo . |
void |
addActionGoto(int pageNo,
int fit)
Adds to this bookmark a
go-to action
capable of changing the current view of the document to
display entire height and width of a
destination
page
pageNo tightly fit inside the window. |
void |
addActionGoto(int pageNo,
PdfRect rect)
Adds to this bookmark a
go-to action
capable of changing the current view of the document to a
rectangular area
rect on a
destination
page pageNo . |
void |
addActionJavaScript(String javascript)
Adds a
Javascript action
to this bookmark.
|
void |
addActionLaunch(String applicationOrFileToLaunch,
boolean print)
Adds a
launch action
to this bookmark.
|
void |
addActionNamed(int namedAction)
Adds a
named action
to this bookmark.
|
void |
addActionRemoteGoTo(String pdfFilePath,
PdfBookmark.RemoteGoTo rGoTo,
boolean newWindow)
Adds a
remote go-to action
to this bookmark.
|
void |
addActionURI(String uri)
Adds a
URI action
to this bookmark.
|
PdfBookmark |
addNext(int namedAction,
String title)
Returns a newly created bookmark (inserted immediately after
this bookmark) with specified
named action.
|
PdfBookmark |
addNext(String title,
int pageNo)
Returns a newly created bookmark (inserted immediately after
this bookmark) that leads to a specified page.
|
PdfBookmark |
addNext(String title,
int pageNo,
double left,
double top,
double zoom)
Returns a newly created bookmark (inserted immediately after
this bookmark) that leads to a
destination
specified by position (
left , top ),
page pageNo , and page magnification factor
zoom . |
PdfBookmark |
addNext(String title,
int pageNo,
double x,
double y,
double width,
double height)
Returns a newly created bookmark (inserted immediately after
this bookmark) that leads to a specified rectangular area on
a specified page.
|
PdfBookmark |
addNext(String title,
int pageNo,
double pos,
int fit)
Returns a newly created bookmark (inserted immediately after
this bookmark) that leads to a destination specified by
pos and fit on page
pageNo . |
PdfBookmark |
addNext(String title,
int pageNo,
int fit)
Returns a newly created bookmark (inserted immediately after
this bookmark) that leads to a
destination
specified by
pageNo and fit . |
PdfBookmark |
addNext(String title,
int pageNo,
PdfRect rect)
Returns a newly created bookmark (inserted immediately after
this bookmark) that leads to a specified rectangle on
specified page.
|
PdfBookmark |
addNext(String title,
String applicationOrFileToLaunch,
boolean print)
Returns a newly created bookmark (inserted immediately after
this bookmark) that launches a specified application or
opens/prints a specified file.
|
PdfBookmark |
addNext(String title,
String javascriptOrURI,
int actionType)
Adds a new bookmark (immediately after this bookmark) that can
execute a specified
JavaScript action
or
URI action.
|
PdfBookmark |
addNext(String title,
String pdfFilePath,
int pageNo,
boolean newWindow)
Adds a new bookmark (immediately after this bookmark) that can
make the viewer application open a specified page of a
another PDF document.
|
PdfBookmark |
addPrevious(int namedAction,
String title)
Returns a newly created bookmark (inserted immediately ahead
of this bookmark) with specified
named action.
|
PdfBookmark |
addPrevious(String title,
int pageNo)
Returns a newly created bookmark (inserted immediately ahead
of this bookmark) that leads to page specified by
pageNo and inserts it immediately ahead of
this bookmark. |
PdfBookmark |
addPrevious(String title,
int pageNo,
double left,
double top,
double zoom)
Returns a newly created bookmark (inserted immediately ahead
of this bookmark) that leads to a
destination
specified by position
(
left , top ),
page pageNo , and page magnification factor
zoom . |
PdfBookmark |
addPrevious(String title,
int pageNo,
double x,
double y,
double width,
double height)
Returns a newly created bookmark (inserted immediately ahead
of this bookmark) that leads to a specified rectangular area
on a specified page.
|
PdfBookmark |
addPrevious(String title,
int pageNo,
double pos,
int fit)
Returns a newly created bookmark (inserted immediately ahead of
this bookmark) that leads to a destination specified by
pos and fit on page
pageNo . |
PdfBookmark |
addPrevious(String title,
int pageNo,
int fit)
Returns a newly created bookmark (inserted immediately ahead
of this bookmark) that leads to a
destination
specified by
pageNo and fit . |
PdfBookmark |
addPrevious(String title,
int pageNo,
PdfRect rect)
Returns a newly created bookmark (inserted immediately ahead
of this bookmark) that leads to a specified rectangle on
specified page.
|
PdfBookmark |
addPrevious(String title,
String applicationOrFileToLaunch,
boolean print)
Returns a newly created bookmark (inserted immediately ahead of
this bookmark) that launches a specified application or
opens/prints a specified file.
|
PdfBookmark |
addPrevious(String title,
String javascriptOrURI,
int actionType)
Adds a new bookmark (immediately before this bookmark) that can
execute a specified
JavaScript action
or
URI action.
|
PdfBookmark |
addPrevious(String title,
String pdfFilePath,
int pageNo,
boolean newWindow)
Adds a new bookmark (immediately before this bookmark) that can
make the viewer application open a specified page of a another
PDF document.
|
List |
getAllActions()
Returns a list of all actions added to this bookmark.
|
List |
getAllActions(int type)
Returns a list of actions of specified type that were added to
this bookmark.
|
Color |
getColor()
Retrieves color currently used to display this bookmark.
|
PdfBookmark |
getFirstChild()
Returns the first child bookmark under
this
bookmark. |
PdfBookmark |
getNext()
Returns bookmark that is immediately after current bookmark.
|
PdfBookmark |
getParentNode()
Returns the bookmark to which
this bookmark is a
child bookmark. |
PdfBookmark |
getPrevious()
Returns bookmark that is immediately ahead of current bookmark.
|
static PdfBookmark.RemoteGoTo |
getRemoteGoToInstance(int pageNo)
Returns a remote go-to destination with specified page number.
|
static PdfBookmark.RemoteGoTo |
getRemoteGoToInstance(int pageNo,
double left,
double bottom,
double right,
double top)
Returns a remote go-to destination with specified page number
and specified position of the window of the viewer application
on the page.
|
static PdfBookmark.RemoteGoTo |
getRemoteGoToInstance(int pageNo,
double pos,
int fit)
Returns a remote go-to destination specified by
pos and fit on specified page
number. |
static PdfBookmark.RemoteGoTo |
getRemoteGoToInstance(int pageNo,
int fit)
Returns a remote go-to destination with specified page number
and location of the window of the viewer application on the
page.
|
static PdfBookmark.RemoteGoTo |
getRemoteGoToInstance(int pageNo,
PdfRect rect)
Returns a remote go-to destination with specified page number
and rectangular area on the page.
|
int |
getStyle()
Retrieves font style currently used to display this bookmark.
|
String |
getTitle()
Retrieves text currently used to display this bookmark.
|
void |
removeAction(int type)
Removes action of specified type from this bookmark.
|
void |
removeAllActions()
Removes all actions added to this bookmark.
|
void |
removeAllActions(int type)
Removes all actions of specified type from this bookmark.
|
void |
removeFirstchild()
Deletes the first child bookmark of this bookmark.
|
void |
removeNext()
Removes the bookmark that is immediately after this bookmark
in this bookmark's level.
|
void |
removePrevious()
Removes the bookmark that is immediately before
this bookmark. |
void |
setColor(Color color)
Specifies color to be used to display this bookmark.
|
void |
setColorAndStyle(Color c,
int s)
Specifies font color and style to be used to display this
bookmark.
|
void |
setStyle(int style)
Specifies font style to be used to display the bookmark.
|
void |
setTitle(String title)
Specifies text to be used to display this bookmark.
|
public static final int FITH
public static final int FITBH
public static final int FITBV
public static final int FITV
public static final int FITB
public static final int FIT
public static final int BOLD
public static final int ITALIC
public static PdfBookmark.RemoteGoTo getRemoteGoToInstance(int pageNo)
pageNo
- number of the page in the external PDF filepublic static PdfBookmark.RemoteGoTo getRemoteGoToInstance(int pageNo, double pos, int fit) throws PdfException
pos
and fit
on specified page
number.pageNo
- number of the page in the external PDF filepos
- horizontal or vertical coordinate of top-left corner
of the window on the pagefit
- constant
specifying how the viewer
application window needs to be placed on a pagePdfException
- if an illegal argument is supplied.public static PdfBookmark.RemoteGoTo getRemoteGoToInstance(int pageNo, int fit) throws PdfException
pageNo
- number of the page in the external PDF filefit
- constant specifying how the viewer
application window needs to be placed on a page;
either FITB
or FIT
PdfException
- if an illegal argument is supplied.public static PdfBookmark.RemoteGoTo getRemoteGoToInstance(int pageNo, PdfRect rect)
pageNo
- number of the pagerect
- rectangular area of the destinationpublic static PdfBookmark.RemoteGoTo getRemoteGoToInstance(int pageNo, double left, double bottom, double right, double top)
pageNo
- number of the page in the external PDF fileleft
- x-coordinate of the position of the top-left corner
of the window on the pagebottom
- y-coordinate of the position of the bottom-right
corner of the window on the pageright
- x-coordinate of the position of the bottom-right
corner of the window on the pagetop
- y-coordinate of the position of the top-left corner
of the window on the pagepublic PdfBookmark addPrevious(String title, int pageNo, double left, double top, double zoom) throws PdfException
left
, top
),
page pageNo
, and page magnification factor
zoom
.title
- text that needs to be used to display the bookmarkpageNo
- number of the destination pageleft
- x-coordinate of the destination positiontop
- y-coordinate of the destination positionzoom
- page magnification factor with which the destination
page needs to be displayedPdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, int pageNo) throws PdfException
pageNo
and inserts it immediately ahead of
this bookmark.title
- text that needs to be used to display the bookmarkpageNo
- number of the pagePdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, int pageNo, double pos, int fit) throws PdfException
pos
and fit
on page
pageNo
.
fit |
pos |
Page Display |
---|---|---|
FITH |
vertical coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire width of the page inside the window. |
FITBH |
vertical coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire width of its bounding box inside the window. |
FITBV |
horizontal coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire height of its bounding box inside the window. |
FITV |
horizontal coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire height of the page inside the window. |
title
- text that needs to be used to display the bookmarkpageNo
- number of the destination pagepos
- horizontal or vertical coordinate of the bookmark's
destinationfit
- constant determining how page needs to be displayed
inside windowPdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, int pageNo, int fit) throws PdfException
pageNo
and fit
.title
- text that needs to be used to display the bookmarkpageNo
- number of the destination pagefit
- FITB
or constant specifiying that entire height
and width of the page's bounding box must be tightly fit
within the windowPdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, int pageNo, PdfRect rect) throws PdfException
title
- text that needs to be used to display the bookmarkpageNo
- number of the page that needs to be displayed when
the bookmark is selectedrect
- rectangular area on the pagePdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, int pageNo, double x, double y, double width, double height) throws PdfException
title
- text that needs to be used to display bookmarkpageNo
- number of the pagex
- x-coordinate of the top-left corner of the
rectangular areay
- y-coordinate of the top-left corner of the
rectangular areawidth
- width of the rectangular areaheight
- height of the rectangular areaPdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(int namedAction, String title) throws PdfException
namedAction
- constant specifying the named actiontitle
- text that needs to be used to display the bookmarkPdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, String javascriptOrURI, int actionType) throws PdfException
title
- text used to display the bookmarkjavascriptOrURI
- JavaScript script that needs to be compiled and
executed or the URI that needs to be launched by the
actionactionType
- either PdfAction.JAVASCRIPT
or
PdfAction.URI
PdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, String applicationOrFileToLaunch, boolean print) throws PdfException
title
- text that needs to be used to display bookmarkapplicationOrFileToLaunch
- pathname of the application or the fileprint
- whether to print the filePdfException
- if an illegal argument is supplied.public PdfBookmark addPrevious(String title, String pdfFilePath, int pageNo, boolean newWindow) throws PdfException
title
- text used to display the bookmarkpdfFilePath
- pathname of the PDF document that needs to be openedpageNo
- number number of the page that needs to be opened by
defaultnewWindow
- whether the other PDF document needs to be opened in
a new windowPdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, int pageNo, double left, double top, double zoom) throws PdfException
left
, top
),
page pageNo
, and page magnification factor
zoom
.title
- text that needs to be used to display the bookmarkpageNo
- number of the destination pageleft
- x-coordinate of the destination positiontop
- y-coordinate of the destination positionzoom
- page magnification factor with which the destination
page needs to be displayedPdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, int pageNo) throws PdfException
title
- text that needs to be used to display the bookmarkpageNo
- number of the pagePdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, int pageNo, double pos, int fit) throws PdfException
pos
and fit
on page
pageNo
.
fit |
pos |
Page Display |
---|---|---|
FITH |
vertical coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire width of the page inside the window. |
FITBH |
vertical coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire width of its bounding box inside the window. |
FITBV |
horizontal coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire height of its bounding box inside the window. |
FITV |
horizontal coordinate of top-left corner of window on the page | Page is zoomed to tightly fit the entire height of the page inside the window. |
title
- text that needs to be used to display the bookmarkpageNo
- number of the destination pagepos
- horizontal or vertical coordinate of the bookmark's
destinationfit
- constant determining how page needs to be displayed
inside windowPdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, int pageNo, int fit) throws PdfException
pageNo
and fit
.title
- text that needs to be used to display the bookmarkpageNo
- number of the destination pagefit
- FITB
or constant specifiying that entire
height and width of the page's bounding box must
be tightly fit within the windowPdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, int pageNo, PdfRect rect) throws PdfException
title
- text that needs to be used to display the bookmarkpageNo
- number of the page that needs to be displayed when
the bookmark is selectedrect
- rectangular area on the pagePdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, int pageNo, double x, double y, double width, double height) throws PdfException
title
- text that needs to be used to display the bookmarkpageNo
- number of the pagex
- x-coordinate of the top-left corner of the
rectangular areay
- y-coordinate of the top-left corner of the
rectangular areawidth
- width of the rectangular areaheight
- height of the rectangular areaPdfException
- if an illegal argument is supplied.public PdfBookmark addNext(int namedAction, String title) throws PdfException
namedAction
- constant specifying the named actiontitle
- text that needs to be used to display the bookmarkPdfException
- if an illegal argument is supplied.PdfAction
public PdfBookmark addNext(String title, String javascriptOrURI, int actionType) throws PdfException
title
- text used to display the bookmarkjavascriptOrURI
- JavaScript script that needs to be compiled and
executed or the URI that needs to be launched by the
actionactionType
- either PdfAction.JAVASCRIPT
or
PdfAction.URI
PdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, String applicationOrFileToLaunch, boolean print) throws PdfException
title
- text that needs to be used to display bookmarkapplicationOrFileToLaunch
- pathname of the application or the fileprint
- whether to print the filePdfException
- if an illegal argument is supplied.public PdfBookmark addNext(String title, String pdfFilePath, int pageNo, boolean newWindow) throws PdfException
title
- text used to display the bookmarkpdfFilePath
- pathname of the PDF document that needs to be openedpageNo
- number number of the page that needs to be opened by
defaultnewWindow
- whether the other PDF document needs to be opened in
a new windowPdfException
- if an illegal argument is supplied.public PdfBookmark getParentNode()
this
bookmark is a
child bookmark.public PdfBookmark getPrevious()
public PdfBookmark getNext()
public void removeFirstchild() throws PdfException
PdfException
- if an illegal argument is supplied.public void removePrevious() throws PdfException
this
bookmark.PdfException
- if an illegal argument is supplied.public void removeNext() throws PdfException
PdfException
- if an illegal argument is supplied.public String getTitle()
setTitle(java.lang.String)
public void setTitle(String title)
title
- text to be used to display the bookmarkgetTitle()
public PdfBookmark getFirstChild() throws PdfException
this
bookmark.PdfException
- if an illegal argument is supplied.public void addActionGoto(int pageNo, double left, double top, double zoom) throws PdfException
left
, top
),
page pageNo
, and magnification factor
zoom
.pageNo
- number of the destination pageleft
- x-coordinate of the top-left corner of the
window on the pagetop
- y-coordinate of the top-left corner of the
window on the pagezoom
- magnification (zoom) factor to be applied when
displaying the pagePdfException
- if an illegal argument is supplied.public void addActionGoto(int pageNo) throws PdfException
pageNo
.pageNo
- number of the destination pagePdfException
- if an illegal argument is supplied.public void addActionGoto(int pageNo, double pos, int fit) throws PdfException
pos
and fit
on page
pageNo
.
fit |
pos |
How page is displayed |
---|---|---|
FITH |
vertical coordinate of top-left corner of window on the page | Page magnification (zoom) factor is adjusted to tightly fit the entire width of the page inside the window |
FITBH |
vertical coordinate of top-left corner of window on the page | Page magnification (zoom) factor is adjusted to tightly fit the entire width of its bounding box inside the window |
FITBV |
horizontal coordinate of top-left corner of window on the page | Page magnification (zoom) factor is adjusted to tightly fit the entire height of its bounding box inside the window |
FITV |
horizontal coordinate of top-left corner of window on the page | Page magnification (zoom) factor is adjusted to tightly fit the entire height of the page inside the window |
pageNo
- number of the destination pagepos
- horizontal or vertical coordinate of top-left
corner of the window on the pagefit
- constant for specifying magnification (zoom) factor
of the pagePdfException
- if an illegal argument is supplied.public void addActionGoto(int pageNo, int fit) throws PdfException
pageNo
tightly fit inside the window.pageNo
- number of the destination pagefit
- constant determining how page needs to be displayed
inside window; either FITB
or FIT
PdfException
- if an illegal argument (constant other than
FITB
) is supplied.public void addActionGoto(int pageNo, PdfRect rect) throws PdfException
rect
on a
destination
page pageNo
.pageNo
- number of the destination pagerect
- rectangular area on the destination pagePdfException
- if an illegal argument is supplied.public void addActionGoto(int pageNo, double x, double y, double width, double height) throws PdfException
pageNo
- number of the pagex
- x-coordinate of the top-left corner of the
rectangular areay
- y-coordinate of the top-left corner of the
rectangular areawidth
- width of the rectangular areaheight
- height of the rectangular areaPdfException
- if an illegal argument is supplied.public void addActionLaunch(String applicationOrFileToLaunch, boolean print)
applicationOrFileToLaunch
- pathname of application that needs to be executed
or pathname of file that needs to be opened or
printed (using the file's default application)print
- whether the file needs to be printed (using its
default application)public void addActionURI(String uri)
uri
- uniform resource indicator (URI) that needs to be
resolvedpublic void addActionNamed(int namedAction)
public void addActionJavaScript(String javascript)
javascript
- a Javascript scriptpublic void addActionRemoteGoTo(String pdfFilePath, PdfBookmark.RemoteGoTo rGoTo, boolean newWindow) throws PdfException
pdfFilePath
- pathname of external PDF filerGoTo
- remote destination in the external PDF filenewWindow
- whether the external PDF file needs to be opened in
a new windowPdfException
- if an illegal argument is supplied.public void addAction(PdfAction action) throws PdfException
PdfAction
.action
- action that the viewer applications need to perform
when they open the documentPdfException
- if an illegal argument is supplied.example
.public List getAllActions()
public List getAllActions(int type) throws PdfException
type
- constant
specifying the
action typePdfException
- if an illegal argument is supplied.public void removeAllActions()
public void removeAction(int type) throws PdfException
type
- constant
specifying the
action typePdfException
- if an illegal argument is supplied.public void removeAllActions(int type) throws PdfException
type
- constant
specifying the
action typePdfException
- if an illegal argument is supplied.public Color getColor()
setColor(java.awt.Color)
public void setColor(Color color)
color
- color to be used to display the bookmarkgetColor()
,
setColorAndStyle(java.awt.Color, int)
public int getStyle()
setStyle(int)
public void setStyle(int style)
style
- style to be used to display the bookmarkgetStyle()
,
setColorAndStyle(java.awt.Color, int)
public void setColorAndStyle(Color c, int s)
setColor
and setStyle
.c
- color to be used to display the bookmarks
- style to be used to display the bookmarksetColor(java.awt.Color)
,
setStyle(int)