Some test text!

Loading...
Guides
User bookmarks

User-defined bookmarks in Android

User-defined bookmarks are a PDFTron specific feature that may not show in other PDF viewer applications. If you want to manage PDF bookmarks so that they can be processed in other standard PDF viewers, see the document outline guide .

The UserBookmarkDialogFragment displays a list of user-defined bookmarks that can be used to navigate the document.

User bookmark dialog

Show user bookmark dialog

To show a user bookmark dialog fragment in your activity, create a new instance of UserBookmarkDialogFragment by calling newInstance() and setting the PDFViewCtrl:

BookmarksDialogFragment showBookmarksDialog(FragmentManager fragmentManager, PDFViewCtrl pdfViewCtrl) {
    DialogFragmentTab userBookmarksDialog = new DialogFragmentTab(
        UserBookmarkDialogFragment.class,
        BookmarksTabLayout.TAG_TAB_BOOKMARK,
        null,
        "User Bookmarks",
        "Bookmarks Dialog",
        null);
    ArrayList<DialogFragmentTab> dialogFragmentTabs = new ArrayList<>();
    dialogFragmentTabs.add(userBookmarksDialog);

    BookmarksDialogFragment bookmarksDialog = BookmarksDialogFragment.newInstance();
    bookmarksDialog.setPdfViewCtrl(pdfViewCtrl)
        .setDialogFragmentTabs(dialogFragmentTabs);
    bookmarksDialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);   
    bookmarksDialog.show(fragmentManager, "bookmarks_dialog");
    return bookmarksDialog;
}

Listener

You can set a listener to be notified when a user bookmark is clicked by calling setUserBookmarkListener(UserBookmarkDialogListener).

Read-only

If the document has write access, users can add new user bookmarks using floating action button. To specify whether the document is read-only call setReadOnly(boolean).

Import and export

It is possible to [import](/api/android/javadoc/reference/com/pdftron/pdf/utils/BookmarkManager.html#importPdfBookmarks(com.pdftron.pdf.PDFViewCtrl, java.lang.String)) and export user bookmarks in JSON format. Typical use case is to save and load the user bookmarks JSON from a server.

The user bookmark JSON is a dictionary with page indices as keys and the bookmark title as the values. For example: {"0":"Bookmark 1","2":"Bookmark 2"}. Behaviour is undefined otherwise. Note that the page indices will be 0-indexed similar to XFDF.

// import
BookmarkManager.importPdfBookmarks(PDFViewCtrl, String);
// export
BookmarkManager.exportPdfBookmarks(PDFDoc);

Get the answers you need: Support

UPCOMING WEBINAR: "2021 in review: Top five new & updated features" Dec 9th @ 11am PT