Skip to content

Reading bookmarks

Foxit PDF SDK for iOS provides reading bookmark APIs via Core SDK. Reading bookmarks differ from PDF outlines: they are application-level markers stored in document Catalog metadata (XML) for quick page jumps.

UI Extensions reading bookmark panel

With the full reader (UI Extensions), users add, view, and jump to reading bookmarks in the side panel—no extra code required.

Core class

ClassDescription
FSReadingBookmarkReading bookmark: title, page index, timestamp

Manage via FSPDFDoc: getReadingBookmarkCount, getReadingBookmark:, insertReadingBookmark:title:pageIndex:, removeReadingBookmark:.

Example: add, enumerate, and remove

objc
#import <FoxitRDK/FSPDFObjC.h>

FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];

// Insert at end
int count = [doc getReadingBookmarkCount];
FSReadingBookmark *newBookmark = [doc insertReadingBookmark:count
                                                     title:@"重要内容"
                                                 pageIndex:5];

// Creation time
FSDateTime *now = [[FSDateTime alloc] init];
[newBookmark setDateTime:now is_creation_date:YES];

// Enumerate
count = [doc getReadingBookmarkCount];
for (int i = 0; i < count; i++) {
    FSReadingBookmark *bookmark = [doc getReadingBookmark:i];
    if ([bookmark isEmpty]) continue;

    NSString *title = [bookmark getTitle];
    int pageIndex = [bookmark getPageIndex];
    NSLog(@"阅读书签: %@, 页码: %d", title, pageIndex);
}

// Remove first
if (count > 0) {
    FSReadingBookmark *first = [doc getReadingBookmark:0];
    [doc removeReadingBookmark:first];
}

[doc saveAs:@"path/to/output.pdf" saveFlags:FSPDFDocSaveFlagNormal];

API reference

See the API reference for FSReadingBookmark.