PTBookmarkManager
@interface PTBookmarkManager : NSObject
An object that manages the user bookmarks inside PDF documents. User bookmarks can be created with
the PTUserBookmark
class and stored inside a PTPDFDoc
with a PTBookmarkManager
instance.
-
Returns the shared bookmark manager object.
Declaration
Objective-C
@property (class, nonatomic, strong, readonly) PTBookmarkManager *_Nonnull defaultManager;
Swift
class var `default`: PTBookmarkManager { get }
-
Returns the root PDF bookmark in the given
PTPDFDoc
used to store user bookmarks.Declaration
Objective-C
- (nullable PTBookmark *)rootPDFBookmarkForDoc:(nonnull PTPDFDoc *)doc create:(BOOL)create;
Swift
func rootPDFBookmark(for doc: PTPDFDoc, create: Bool) -> PTBookmark?
Parameters
doc
the
PTPDFDoc
containing user bookmarkscreate
YES
to create the root PDF bookmark if not found,NO
otherwiseReturn Value
the root PDF bookmark in the given
PTPDFDoc
, ornil
if not found and not created. -
Removes the root PDF bookmark in the given
PTPDFDoc
used to store user bookmarks.Declaration
Objective-C
- (BOOL)removeRootPDFBookmarkForDoc:(nonnull PTPDFDoc *)doc;
Swift
func removeRootPDFBookmark(for doc: PTPDFDoc) -> Bool
Parameters
doc
the
PTPDFDoc
containing user bookmarksReturn Value
YES
if the root bookmark was found and removed,NO
otherwise -
Returns the user bookmarks for the given
PTPDFDoc
.Declaration
Objective-C
- (nonnull NSArray<PTUserBookmark *> *)bookmarksForDoc:(nonnull PTPDFDoc *)doc;
Swift
func bookmarks(for doc: PTPDFDoc) -> [PTUserBookmark]
Parameters
doc
the
PTPDFDoc
containing user bookmarksReturn Value
the user bookmarks for the given
PTPDFDoc
-
Returns the user bookmarks for the given
PTPDFDoc
rooted at the specified PDF bookmark.Declaration
Objective-C
- (nonnull NSArray<PTUserBookmark *> *)bookmarksForDoc:(nonnull PTPDFDoc *)doc rootPDFBookmark:(nullable PTBookmark *) rootPDFBookmark;
Swift
func bookmarks(for doc: PTPDFDoc, rootPDFBookmark: PTBookmark?) -> [PTUserBookmark]
Parameters
doc
the
PTPDFDoc
containing user bookmarksrootPDFBookmark
the root PDF bookmark
Return Value
the user bookmarks for the given
PTPDFDoc
rooted at the specified PDF bookmark -
Saves the user bookmarks for the given
PTPDFDoc
.Declaration
Objective-C
- (void)saveBookmarks:(nonnull NSArray<PTUserBookmark *> *)bookmarks forDoc:(nonnull PTPDFDoc *)doc;
Swift
func save(_ bookmarks: [PTUserBookmark], for doc: PTPDFDoc)
Parameters
bookmarks
the user bookmarks to save
doc
the
PTPDFDoc
to save the bookmarks inside -
Adds a user bookmark for the given
PTPDFDoc
.Declaration
Objective-C
- (void)addBookmark:(nonnull PTUserBookmark *)bookmark forDoc:(nonnull PTPDFDoc *)doc;
Swift
func add(_ bookmark: PTUserBookmark, for doc: PTPDFDoc)
Parameters
bookmark
the user bookmark to add to the document
doc
the
PTPDFDoc
to add the bookmark to -
Updates the user bookmarks in a document after a page has been moved.
Declaration
Objective-C
- (void)updateBookmarksForDoc:(nonnull PTPDFDoc *)doc pageMovedFromPageNumber:(int)oldPageNumber pageObjNum:(unsigned int)oldPageObjNum toPageNumber:(int)newPageNumber pageObjNum:(unsigned int)newPageObjNum;
Swift
func updateBookmarks(for doc: PTPDFDoc, pageMovedFromPageNumber oldPageNumber: Int32, pageObjNum oldPageObjNum: UInt32, toPageNumber newPageNumber: Int32, pageObjNum newPageObjNum: UInt32)
Parameters
doc
the
PTPDFDoc
containing user bookmarks to updateoldPageNumber
the page’s original page number
oldPageObjNum
the page’s original SDF object number
newPageNumber
the page’s new page number
newPageObjNum
the page’s new SDF object number
-
Converts users bookmarks in JSON format to a list of
PTUserBookmark
objects. The format of the JSON string is: {“0”: “Bookmark 1”, “1”: “Bookmark 2”}Declaration
Objective-C
- (nullable NSArray<PTUserBookmark *> *)bookmarksFromJSONString: (nonnull NSString *)jsonString;
Swift
func bookmarks(fromJSONString jsonString: String) -> [PTUserBookmark]?
Parameters
jsonString
the user bookmarks in JSON format
Return Value
the list of
PTUserBookmark
objects, ornil
if the conversion failed -
Converts a list of
PTUserBookmark
objects to a JSON format. The format of the JSON string is: {“0”: “Bookmark 1”, “1”: “Bookmark 2”}Declaration
Objective-C
- (nullable NSString *)JSONStringFromBookmarks: (nonnull NSArray<PTUserBookmark *> *)bookmarks;
Swift
func jsonString(from bookmarks: [PTUserBookmark]) -> String?
Parameters
bookmarks
the list of
PTUserBookmark
objects to convertReturn Value
the user bookmarks in JSON format, or
nil
if the conversion failed -
Imports user bookmarks in JSON format to the specified document. The format of the JSON string is: {“0”: “Bookmark 1”, “1”: “Bookmark 2”}
Declaration
Objective-C
- (void)importBookmarksForDoc:(nonnull PTPDFDoc *)doc fromJSONString:(nonnull NSString *)jsonString;
Swift
func importBookmarks(for doc: PTPDFDoc, fromJSONString jsonString: String)
Parameters
doc
the
PTPDFDoc
to save the bookmarks insidejsonString
the user bookmarks in JSON format
-
Export user bookmarks in JSON format from the specified document. The format of the JSON string is: {“0”: “Bookmark 1”, “1”: “Bookmark 2”}
Declaration
Objective-C
- (nullable NSString *)exportBookmarksFromDoc:(nonnull PTPDFDoc *)doc;
Swift
func exportBookmarks(from doc: PTPDFDoc) -> String?
Parameters
doc
the
PTPDFDoc
to export the bookmarks fromReturn Value
the user bookmarks in JSON format, or
nil
if the document contains no bookmarks or the JSON conversion failed