public class

BookmarkManager

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.utils.BookmarkManager

Class Overview

A utility class for handling bookmarks in PDF

Summary

Public Constructors
BookmarkManager()
Public Methods
static void addPdfBookmark(Context context, PDFViewCtrl pdfViewCtrl, long pageObjNum, int pageNumber)
Adds a PDF bookmark.
static void addUserBookmark(Context context, String filePath, long pageObjNum, int pageNumber)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Adds a user bookmark
static void addUserBookmark(Context context, PDFViewCtrl pdfViewCtrl, String filePath, long pageObjNum, int pageNumber)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Adds a user bookmark
static String exportPdfBookmarks(PDFDoc pdfDoc)
Exports user bookmark json from a document
static String exportUserBookmarks(Context context, String filePath)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Exports user bookmark json from a document
static ArrayList<UserBookmarkItem> fromJSON(String bookmarkJson)
Converts user bookmarks json to list of UserBookmarkItem
static ArrayList<Bookmark> getBookmarkList(PDFDoc pdfDoc, Bookmark firstSibling)
Returns the list of sibling bookmarks after the specified bookmark.
static ArrayList<Bookmark> getBookmarkListByTitle(PDFDoc pdfDoc, String queryText, boolean isSearchActive)
Returns the list of sibling bookmarks after the specified bookmark.
static ArrayList<Integer> getPdfBookmarkedPageNumbers(PDFDoc pdfDoc)
Returns array of integer indicate page number that contains bookmark
static List<UserBookmarkItem> getPdfBookmarks(PDFDoc pdfDoc, String queryText)
Returns pdf bookmarks.
static List<UserBookmarkItem> getPdfBookmarks(Bookmark rootBookmark)
Returns pdf bookmarks.
static List<UserBookmarkItem> getPdfBookmarks(PDFDoc pdfDoc)
Returns pdf bookmarks.
static List<UserBookmarkItem> getPdfBookmarks(Bookmark rootBookmark, String queryText)
Returns pdf bookmarks.
static Bookmark getRootPdfBookmark(PDFDoc pdfDoc, boolean createNew)
Returns the root PDF bookmark
static List<UserBookmarkItem> getUserBookmarks(Context context, String filePath)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Returns user bookmarks.
static List<UserBookmarkItem> getUserBookmarks(Context context, String filePath, String queryText)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Returns user bookmarks.
static void importPdfBookmarks(PDFViewCtrl pdfViewCtrl, String bookmarkJson)
Imports user bookmark json to a document This will save the user bookmarks to the associated PDFDoc
static void importUserBookmarks(Context context, PDFViewCtrl pdfViewCtrl, String filePath, String bookmarkJson)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Imports user bookmark json to SharedPreferences This will NOT alter the document
static void importUserBookmarks(Context context, String filePath, String bookmarkJson)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Imports user bookmark json to SharedPreferences This will NOT alter the document
static void onPageDeleted(Context context, PDFViewCtrl pdfViewCtrl, String filePath, Long objNumber, int pageNumber, int pageCount)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is deleted.
static void onPageDeleted(PDFViewCtrl pdfViewCtrl, Long objNumber)
Handles bookmarks when a pdf bookmark is deleted.
static void onPageDeleted(Context context, String filePath, Long objNumber, int pageNumber, int pageCount)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is deleted.
static void onPageMoved(PDFViewCtrl pdfViewCtrl, long objNumber, long newObjNumber, int newPageNumber, boolean rebuild)
Handles bookmarks when a pdf bookmarks is moved.
static void onPageMoved(Context context, String filePath, long objNumber, long newObjNumber, int oldPageNumber, int newPageNumber)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is moved.
static void onPageMoved(Context context, PDFViewCtrl pdfViewCtrl, String filePath, long objNumber, long newObjNumber, int oldPageNumber, int newPageNumber)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is moved.
static void removePdfBookmark(Context context, PDFViewCtrl pdfViewCtrl, long pageObjNum, int pageNumber)
Removes a PDF bookmark.
static boolean removeRootPdfBookmark(PDFViewCtrl pdfViewCtrl, boolean shouldTakeUndoSnapshot)
Removes the root PDF bookmark.
static void removeUserBookmark(Context context, PDFViewCtrl pdfViewCtrl, String filePath, long pageObjNum, int pageNumber)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Removes a user bookmark
static void removeUserBookmark(Context context, String filePath, long pageObjNum, int pageNumber)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Removes a user bookmark
static void removeUserBookmarks(Context context, String filePath)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Removes user bookmarks.
static void savePdfBookmarks(PDFViewCtrl pdfViewCtrl, List<UserBookmarkItem> data, boolean shouldTakeUndoSnapshot, boolean rebuild)
Saves PDF bookmarks.
static void saveUserBookmarks(Context context, String filePath, List<UserBookmarkItem> data)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Saves user bookmarks.
static void saveUserBookmarks(Context context, PDFViewCtrl pdfViewCtrl, String filePath, List<UserBookmarkItem> data)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Saves user bookmarks.
static String toJSON(List<UserBookmarkItem> bookmarkItems)
Converts list of UserBookmarkItem to user bookmarks json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
static void updateUserBookmarkPageObj(Context context, PDFViewCtrl pdfViewCtrl, String filePath, long pageObjNum, long newPageObjNum, int newPageNum)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Updates user bookmark page object number.
static void updateUserBookmarkPageObj(Context context, String filePath, long pageObjNum, long newPageObjNum, int newPageNum)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Updates user bookmark page object number.
static void updateUserBookmarksFilePath(Context context, String oldPath, String newPath)
ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Updates user bookmark file path.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BookmarkManager ()

Public Methods

public static void addPdfBookmark (Context context, PDFViewCtrl pdfViewCtrl, long pageObjNum, int pageNumber)

Adds a PDF bookmark.

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
pageObjNum The page object number
pageNumber The page number

public static void addUserBookmark (Context context, String filePath, long pageObjNum, int pageNumber)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Adds a user bookmark

Parameters
context The context
filePath The file path
pageObjNum The page object number
pageNumber The page number

public static void addUserBookmark (Context context, PDFViewCtrl pdfViewCtrl, String filePath, long pageObjNum, int pageNumber)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Adds a user bookmark

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
filePath The file path
pageObjNum The page object number
pageNumber The page number

public static String exportPdfBookmarks (PDFDoc pdfDoc)

Exports user bookmark json from a document

Parameters
pdfDoc the document
Returns
  • the user bookmark json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
Throws
JSONException

public static String exportUserBookmarks (Context context, String filePath)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Exports user bookmark json from a document

Parameters
context the Context
filePath the file path
Returns
  • the user bookmark json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
Throws
JSONException

public static ArrayList<UserBookmarkItem> fromJSON (String bookmarkJson)

Converts user bookmarks json to list of UserBookmarkItem

Parameters
bookmarkJson the user bookmark json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
Returns
Throws
JSONException

public static ArrayList<Bookmark> getBookmarkList (PDFDoc pdfDoc, Bookmark firstSibling)

Returns the list of sibling bookmarks after the specified bookmark. Note: if the specified bookmark is null the sibling bookmarks after the first bookmark in the document will be returned. If the specified bookmark is null and there is no sibling then all bookmarks under the first bookmark will be returned.

Parameters
pdfDoc The PDF doc
firstSibling The first sibling
Returns
  • The list of sibling bookmarks after the specified bookmark

public static ArrayList<Bookmark> getBookmarkListByTitle (PDFDoc pdfDoc, String queryText, boolean isSearchActive)

Returns the list of sibling bookmarks after the specified bookmark. Note: if the specified bookmark is null the sibling bookmarks after the first bookmark in the document will be returned. If the specified bookmark is null and there is no sibling then all bookmarks under the first bookmark will be returned.

Parameters
pdfDoc The PDF doc
queryText The string used to filter bookmarks by title
isSearchActive Boolean to indicate if search is active
Returns
  • The list of sibling bookmarks after the specified bookmark

public static ArrayList<Integer> getPdfBookmarkedPageNumbers (PDFDoc pdfDoc)

Returns array of integer indicate page number that contains bookmark

public static List<UserBookmarkItem> getPdfBookmarks (PDFDoc pdfDoc, String queryText)

Returns pdf bookmarks.

Parameters
pdfDoc the document
queryText The string used to filter bookmarks by title
Returns
  • A list of user bookmarks

public static List<UserBookmarkItem> getPdfBookmarks (Bookmark rootBookmark)

Returns pdf bookmarks.

Parameters
rootBookmark The root PDF bookmark
Returns
  • A list of user bookmarks

public static List<UserBookmarkItem> getPdfBookmarks (PDFDoc pdfDoc)

Returns pdf bookmarks.

Parameters
pdfDoc the document
Returns
  • A list of user bookmarks

public static List<UserBookmarkItem> getPdfBookmarks (Bookmark rootBookmark, String queryText)

Returns pdf bookmarks.

Parameters
rootBookmark The root PDF bookmark
queryText The string used to filter bookmarks by title
Returns
  • A list of user bookmarks

public static Bookmark getRootPdfBookmark (PDFDoc pdfDoc, boolean createNew)

Returns the root PDF bookmark

Parameters
pdfDoc The PDFDoc
createNew True if should create new bookmark object if doc doesn't have any
Returns
  • The root PDF bookmark

public static List<UserBookmarkItem> getUserBookmarks (Context context, String filePath)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Returns user bookmarks.

Parameters
context The context
filePath The file path
Returns
  • a list of user bookmarks

public static List<UserBookmarkItem> getUserBookmarks (Context context, String filePath, String queryText)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Returns user bookmarks.

Parameters
context The context
filePath The file path
queryText The string used to filter bookmarks by title
Returns
  • a list of user bookmarks

public static void importPdfBookmarks (PDFViewCtrl pdfViewCtrl, String bookmarkJson)

Imports user bookmark json to a document This will save the user bookmarks to the associated PDFDoc

Parameters
pdfViewCtrl the PDFViewCtrl associated with the document
bookmarkJson the user bookmark json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
Throws
JSONException

public static void importUserBookmarks (Context context, PDFViewCtrl pdfViewCtrl, String filePath, String bookmarkJson)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Imports user bookmark json to SharedPreferences This will NOT alter the document

Parameters
context the Context
pdfViewCtrl the PDFViewCtrl
filePath the file path
bookmarkJson the user bookmark json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
Throws
JSONException

public static void importUserBookmarks (Context context, String filePath, String bookmarkJson)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Imports user bookmark json to SharedPreferences This will NOT alter the document

Parameters
context the Context
filePath the file path
bookmarkJson the user bookmark json in format: {"0":"Bookmark 1","1":"Bookmark 2"}
Throws
JSONException

public static void onPageDeleted (Context context, PDFViewCtrl pdfViewCtrl, String filePath, Long objNumber, int pageNumber, int pageCount)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is deleted.

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
filePath The file path
objNumber The page object number
pageNumber The page number
pageCount The number of pages

public static void onPageDeleted (PDFViewCtrl pdfViewCtrl, Long objNumber)

Handles bookmarks when a pdf bookmark is deleted.

Parameters
pdfViewCtrl The PDFViewCtrl
objNumber The object number

public static void onPageDeleted (Context context, String filePath, Long objNumber, int pageNumber, int pageCount)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is deleted.

Parameters
context The context
filePath The file path
objNumber The page object number
pageNumber The page number
pageCount The number of pages

public static void onPageMoved (PDFViewCtrl pdfViewCtrl, long objNumber, long newObjNumber, int newPageNumber, boolean rebuild)

Handles bookmarks when a pdf bookmarks is moved.

Parameters
pdfViewCtrl The PDFViewCtrl
objNumber The object number before moving
newObjNumber The object number after moving
newPageNumber The new page number
rebuild True if should rebuild the root bookmark

public static void onPageMoved (Context context, String filePath, long objNumber, long newObjNumber, int oldPageNumber, int newPageNumber)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is moved.

Parameters
context The context
filePath The file path
objNumber The old page object number
newObjNumber The new page object number
oldPageNumber The page number before moving
newPageNumber the page number after moving

public static void onPageMoved (Context context, PDFViewCtrl pdfViewCtrl, String filePath, long objNumber, long newObjNumber, int oldPageNumber, int newPageNumber)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Handles bookmarks when a user bookmarks is moved.

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
filePath The file path
objNumber The old page object number
newObjNumber The new page object number
oldPageNumber The page number before moving
newPageNumber the page number after moving

public static void removePdfBookmark (Context context, PDFViewCtrl pdfViewCtrl, long pageObjNum, int pageNumber)

Removes a PDF bookmark. A write lock is expected around this call.

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
pageObjNum The page object number
pageNumber The page number

public static boolean removeRootPdfBookmark (PDFViewCtrl pdfViewCtrl, boolean shouldTakeUndoSnapshot)

Removes the root PDF bookmark.

Parameters
pdfViewCtrl The PDFViewCtrl
shouldTakeUndoSnapshot True if should take undo snapshot
Returns
  • True if the root PDF bookmark is removed.

public static void removeUserBookmark (Context context, PDFViewCtrl pdfViewCtrl, String filePath, long pageObjNum, int pageNumber)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Removes a user bookmark

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
filePath The file path
pageObjNum The page object number
pageNumber The page number

public static void removeUserBookmark (Context context, String filePath, long pageObjNum, int pageNumber)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Removes a user bookmark

Parameters
context The context
filePath The file path
pageObjNum The page object number
pageNumber The page number

public static void removeUserBookmarks (Context context, String filePath)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Removes user bookmarks.

Parameters
context The context
filePath The file path

public static void savePdfBookmarks (PDFViewCtrl pdfViewCtrl, List<UserBookmarkItem> data, boolean shouldTakeUndoSnapshot, boolean rebuild)

Saves PDF bookmarks.

Parameters
pdfViewCtrl the PDFViewCtrl
data A list of user bookmarks
shouldTakeUndoSnapshot True if should take undo snapshot
rebuild True if should rebuild the root bookmark

public static void saveUserBookmarks (Context context, String filePath, List<UserBookmarkItem> data)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Saves user bookmarks.

Parameters
context The context
filePath The file path
data The user bookmarks

public static void saveUserBookmarks (Context context, PDFViewCtrl pdfViewCtrl, String filePath, List<UserBookmarkItem> data)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Saves user bookmarks.

Parameters
context The context
filePath The file path
data The user bookmarks

public static String toJSON (List<UserBookmarkItem> bookmarkItems)

Converts list of UserBookmarkItem to user bookmarks json in format: {"0":"Bookmark 1","1":"Bookmark 2"}

Parameters
bookmarkItems the list of UserBookmarkItem
Returns
  • the user bookmark json in format:
Throws
JSONException

public static void updateUserBookmarkPageObj (Context context, PDFViewCtrl pdfViewCtrl, String filePath, long pageObjNum, long newPageObjNum, int newPageNum)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Updates user bookmark page object number.

Parameters
context The context
pdfViewCtrl The PDFViewCtrl
filePath The file path
pageObjNum The old page object number
newPageObjNum The new page object number
newPageNum The new page number

public static void updateUserBookmarkPageObj (Context context, String filePath, long pageObjNum, long newPageObjNum, int newPageNum)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Updates user bookmark page object number.

Parameters
context The context
filePath The file path
pageObjNum The old page object number
newPageObjNum The new page object number
newPageNum The new page number

public static void updateUserBookmarksFilePath (Context context, String oldPath, String newPath)

ONLY USE WHEN DOCUMENT CANNOT BE ALTERED Updates user bookmark file path.

Parameters
context The context
oldPath The old file path
newPath The new file path