Class Bookmark


  • public class Bookmark
    extends Object
    Represents a PDF bookmark as seen in the sidebar of PDF reader software to help users navigate.

    Bookmarks are arranged and navigated in a parent/child node hierarchy, similar to an HTML DOM.

    • Constructor Detail

      • Bookmark

        public Bookmark​(@Nonnull
                        String text,
                        int pageIndex,
                        @Nullable
                        String parentBookmarkText,
                        BookmarkDestinations destinationType,
                        @Nullable
                        String nextBookmarkText,
                        @Nullable
                        String previousBookmarkText)
        Instantiates a new Bookmark.
        Parameters:
        text - the display text of the bookmark
        pageIndex - the zero based page number that the bookmark links to.
        parentBookmarkText - the text of parent bookmark which contains this bookmark. Null if it is root bookmark.
        destinationType - the type of destination represented by the bookmark
        nextBookmarkText - the text of next bookmark at the current level, if any. Null if it is last bookmark.
        previousBookmarkText - the previous bookmark at the current level, if any. Null if it is first bookmark.
    • Method Detail

      • getDestinationType

        public final BookmarkDestinations getDestinationType()
        Gets destination type. Type of destination represented by the bookmark.
        Returns:
        the destination type
      • getNextBookmarkText

        public final String getNextBookmarkText()
        Gets next bookmark text. The text of next bookmark at the current level, if any. Null if it is last bookmark.
        Returns:
        the next bookmark text
      • getPageIndex

        public final int getPageIndex()
        Gets page index. The zero based page number that the bookmark links to.
        Returns:
        the page index
      • addNextBookmark

        public final void addNextBookmark​(String text,
                                          int pageIndex)
        Add a new bookmark after this bookmark
        Parameters:
        text - the display text of the bookmark
        pageIndex - the zero based page number that the bookmark links to.
      • getParentBookmarkText

        public final String getParentBookmarkText()
        Gets parent bookmark text. The text of parent bookmark which contains this bookmark. Null if it is root bookmark.
        Returns:
        the parent bookmark text
      • getText

        public final String getText()
        Gets text. The display text of the bookmark.
        Returns:
        the text
      • setText

        public final void setText​(String value)
        Sets text. The display text of the bookmark
        Parameters:
        value - the value
      • AddPreviousBookmark

        public final void AddPreviousBookmark​(String text,
                                              int pageIndex)
        Add a new bookmark before this bookmark
        Parameters:
        text - the display text of the bookmark
        pageIndex - the zero based page number that the bookmark links to.
      • getPreviousBookmarkText

        public final String getPreviousBookmarkText()
        Gets previous bookmark text. Previous bookmark at the current level, if any. Null if it is first bookmark.
        Returns:
        the previous bookmark text.
      • AddChildBookmark

        public final Bookmark AddChildBookmark​(String text,
                                               int pageIndex)
        Add a new bookmark as a first child of this bookmark.

        To add a bookmark as a second child, please navigate to the childBookmark object and call AddNextBookmark.

        Parameters:
        text - the display text of the bookmark
        pageIndex - the zero based page number that the bookmark links to.
        Returns:
        a new child bookmark