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 bookmarks

    create

    YES to create the root PDF bookmark if not found, NO otherwise

    Return Value

    the root PDF bookmark in the given PTPDFDoc, or nil 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 bookmarks

    Return 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 bookmarks

    Return 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 bookmarks

    rootPDFBookmark

    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 deleted.

    Declaration

    Objective-C

    - (void)updateBookmarksForDoc:(nonnull PTPDFDoc *)doc
        pageDeletedWithPageObjNum:(unsigned int)pageObjNum;

    Swift

    func updateBookmarks(for doc: PTPDFDoc, pageDeletedWithPageObjNum pageObjNum: UInt32)

    Parameters

    doc

    the PTPDFDoc containing user bookmarks to update

    pageObjNum

    the SDF object number of the deleted PTPage

  • 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 update

    oldPageNumber

    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, or nil 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 convert

    Return 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 inside

    jsonString

    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 from

    Return Value

    the user bookmarks in JSON format, or nil if the document contains no bookmarks or the JSON conversion failed