PTBookmarkUtils
@interface PTBookmarkUtils : NSObject
A utility class for managing user bookmarks. Note the the PDF specification does not account for user bookmarks. Therefore user bookmarks are non-portable between PDF readers. PDFNet for iOS stores the bookmarks in the iOS user preferences.
The bookmark data is an NSArray of NSDictionary-s. Each NSDictionary represents a bookmark. The NSDictionary entries are: {@“page-number” : NSNumber numberWithInt}, {@“sdf-obj-number” : NSNumber numberWithInt}, {@“name” : NSString}, {@“unique-id” : NSString (a UUID string)}
-
This method updates a file’s bookmark data when the file is moved. If this method is not called when a file is moved, its bookmarks will no longer be associated with the file.
Declaration
Objective-C
+ (void)fileMovedFrom:(nonnull NSURL *)oldLocation to:(nonnull NSURL *)newLocation;
Swift
class func fileMoved(from oldLocation: URL, to newLocation: URL)
Parameters
oldLocation
The former location of the PDF file.
newLocation
The present location of the PDF file.
-
This method saves bookmark data back to disk.
Declaration
Objective-C
+ (void)saveBookmarkData:(nullable NSArray *)bookmarkData forFileUrl:(nonnull NSURL *)url;
Swift
class func saveBookmarkData(_ bookmarkData: [Any]?, forFileUrl url: URL)
Parameters
bookmarkData
The bookmark data. See class documentation for data structure description.
url
The location of the PDF file.
-
Retrieves the bookmark data from disk.
Declaration
Objective-C
+ (nonnull NSArray<NSMutableDictionary *> *)bookmarkDataForDocument: (nonnull NSURL *)documentUrl;
Swift
class func bookmarkData(forDocument documentUrl: URL) -> [NSMutableDictionary]
Parameters
documentUrl
The location of the PDF file.
Return Value
The bookmark data. See class documentation for data structure description.
-
Used to update user bookmarks when the
PTPDFDoc
‘s page is moved.Declaration
Objective-C
+ (nonnull NSMutableArray<NSMutableDictionary *> *) updateUserBookmarks: (nonnull NSMutableArray<NSMutableDictionary *> *)bookmarks oldPageNumber:(unsigned int)oldPageNumber newPageNumber:(unsigned int)newPageNumber oldSDFNumber:(unsigned int)oldSDFNumber newSDFNumber:(unsigned int)newSDFNumber;
Swift
class func updateUserBookmarks(_ bookmarks: NSMutableArray, oldPageNumber: UInt32, newPageNumber: UInt32, oldSDFNumber: UInt32, newSDFNumber: UInt32) -> NSMutableArray
Parameters
bookmarks
The current bookmarks.
oldPageNumber
The original position of the page.
newPageNumber
The new position of the page.
oldSDFNumber
The SDF number of the page at the original location.
newSDFNumber
The SDF number of the page at the new location.
-
Deletes the bookmark data for the given document.
Declaration
Objective-C
+ (void)deleteBookmarkDataForDocument:(nonnull NSURL *)documentURL;
Swift
class func deleteBookmarkData(forDocument documentURL: URL)
Parameters
documentURL
The location of the PDF file.
-
Undocumented
Declaration
Objective-C
- (instancetype)init PT_UNAVAILABLE_MSG("Utility has no instance methods.");