Outline
Foxit PDF SDK for iOS provides PDF outline (bookmark) read, create, edit, and delete via Core SDK. Outlines form a tree: each node can have a title, destination, or action for navigation.
UI Extensions outline panel
With the full reader (UI Extensions), the outline panel lets users browse and jump to nodes—no extra code required.
Core classes
| Class | Description |
|---|---|
FSBookmark | Outline node: title, color, style, destination, action |
FSDestination | Target page and zoom |
FSAction | Action on a node (GoTo, URI, etc.) |
Outline tree
Get the root with [FSPDFDoc getRootBookmark]. The root is abstract (no title); it is the tree entry. If the document has no outline, use [FSPDFDoc createRootBookmark].
Traverse with getFirstChild, getNextSibling, getParent, and related APIs.
Position constants
| Constant | Description |
|---|---|
FSBookmarkPosFirstChild | First child |
FSBookmarkPosLastChild | Last child |
FSBookmarkPosPrevSibling | Previous sibling |
FSBookmarkPosNextSibling | Next sibling |
FSBookmarkPosFirstSibling | First sibling |
FSBookmarkPosLastSibling | Last sibling |
Style constants
| Constant | Description |
|---|---|
FSBookmarkStyleNormal | Normal |
FSBookmarkStyleItalic | Italic |
FSBookmarkStyleBold | Bold |
Example: depth-first traversal
objc
#import <FoxitRDK/FSPDFObjC.h>
FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];
FSBookmark *root = [doc getRootBookmark];
if (root && ![root isEmpty]) {
[self traverseBookmarks:[root getFirstChild] doc:doc];
}
- (void)traverseBookmarks:(FSBookmark *)bookmark doc:(FSPDFDoc *)doc {
if (!bookmark || [bookmark isEmpty]) return;
NSString *title = [bookmark getTitle];
FSDestination *dest = [bookmark getDestination];
if (dest && ![dest isEmpty]) {
int pageIndex = [dest getPageIndex:doc];
NSLog(@"书签: %@, 页码: %d", title, pageIndex);
}
// Children
if ([bookmark hasChild]) {
[self traverseBookmarks:[bookmark getFirstChild] doc:doc];
}
// Siblings
[self traverseBookmarks:[bookmark getNextSibling] doc:doc];
}Example: create outline nodes
objc
FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];
FSBookmark *root = [doc getRootBookmark];
if (!root || [root isEmpty]) {
root = [doc createRootBookmark];
}
// Child under root
FSBookmark *chapter1 = [root insert:@"第一章 概述" position:FSBookmarkPosLastChild];
FSDestination *dest = [FSDestination createFitPage:doc pageIndex:0];
[chapter1 setDestination:dest];
[chapter1 setColor:0x0000FF];
[chapter1 setStyle:FSBookmarkStyleBold];
// Child under chapter
FSBookmark *section1 = [chapter1 insert:@"1.1 背景" position:FSBookmarkPosLastChild];
[section1 setDestination:[FSDestination createXYZ:doc pageIndex:0
left:0 top:500 zoom:1.0f]];
[doc saveAs:@"path/to/output.pdf" saveFlags:FSPDFDocSaveFlagNormal];API reference
See the API reference for FSBookmark, FSDestination, and FSAction.