Package com.snowtide.pdf
Class Bookmark
- java.lang.Object
-
- com.snowtide.pdf.Bookmark
-
public class Bookmark extends Object
Instances of this class form a singly-rooted tree available in some PDF documents. The elements in such a tree, available via the
Document.getBookmarks()
function, refer to a page within the source PDF document. In addition, some Bookmarks may also refer to a position on the referred page, further specifying the location of a section of interest within the source PDF document.- Since:
- v1.3.5
- Version:
- ©2004-2024 Snowtide
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Bookmark>
getAllChildren()
Returns a new List of the direct descendants of this bookmark.int
getAllChildren(List dest)
Adds all of the direct descendants of this bookmark to the given list.List<Bookmark>
getAllDescendants()
Performs a full descent of the bookmark tree rooted at this bookmark, adding all descendant child bookmarks to a new list, which is returned.int
getAllDescendants(List dest)
Performs a full descent of the bookmark tree rooted at this bookmark, adding all descendant child bookmarks to the given list.float
getBottomBound()
Returns the y-coordinate on the page to which this bookmark refers where a PDF viewer should position the bottom edge of its window when the bookmark is activated.Bookmark
getChild(int n)
Returns the n-th child of this bookmark.int
getChildCnt()
Returns the number of children this bookmark contains.String
getDestinationName()
Returns the name of the destination associated with thisBookmark
.float
getLeftBound()
Returns the x-coordinate on the page to which this bookmark refers where a PDF viewer should position the left edge of its window when the bookmark is activated.int
getPageNumber()
Returns the page number for this bookmark.float
getRightBound()
Returns the x-coordinate on the page to which this bookmark refers where a PDF viewer should position the right edge of its window when the bookmark is activated.String
getTitle()
Returns the title/label for this bookmark.float
getTopBound()
Returns the y-coordinate on the page to which this bookmark refers where a PDF viewer should position the top edge of its window when the bookmark is activated.
-
-
-
Method Detail
-
getTitle
public String getTitle()
Returns the title/label for this bookmark. May be null, especially if this bookmark is the root of a PDF document's bookmark tree.
-
getDestinationName
public String getDestinationName()
Returns the name of the destination associated with thisBookmark
. This value may be null if thisBookmark
is not associated with a named destination.
-
getPageNumber
public int getPageNumber()
Returns the page number for this bookmark. The page number is 0-based, and can be used to access the corresponding page object via the parentDocument
'sDocument.getPage(int)
method. This function may return -1 if no page number is specified for a bookmark; this is very likely if this bookmark is the root of a PDF document's bookmark tree.
-
getLeftBound
public float getLeftBound()
Returns the x-coordinate on the page to which this bookmark refers where a PDF viewer should position the left edge of its window when the bookmark is activated. If unspecified, this function will return -1.
-
getRightBound
public float getRightBound()
Returns the x-coordinate on the page to which this bookmark refers where a PDF viewer should position the right edge of its window when the bookmark is activated. If unspecified, this function will return -1.
-
getTopBound
public float getTopBound()
Returns the y-coordinate on the page to which this bookmark refers where a PDF viewer should position the top edge of its window when the bookmark is activated. If unspecified, this function will return -1.
-
getBottomBound
public float getBottomBound()
Returns the y-coordinate on the page to which this bookmark refers where a PDF viewer should position the bottom edge of its window when the bookmark is activated. If unspecified, this function will return -1.
-
getChildCnt
public int getChildCnt()
Returns the number of children this bookmark contains.
-
getChild
public Bookmark getChild(int n)
Returns the n-th child of this bookmark.- Throws:
IndexOutOfBoundsException
- ifn
is out of range (n < 0 || n >=getChildCnt()
).
-
getAllChildren
public int getAllChildren(List dest)
Adds all of the direct descendants of this bookmark to the given list.- Returns:
- the number of bookmarks added to the given list
-
getAllChildren
public List<Bookmark> getAllChildren()
Returns a new List of the direct descendants of this bookmark. The returned List is guaranteed to provide fast random access.
-
getAllDescendants
public int getAllDescendants(List dest)
Performs a full descent of the bookmark tree rooted at this bookmark, adding all descendant child bookmarks to the given list.- Returns:
- the number of bookmarks added to the given list
-
-