Some test text!

menu
search

Outline tree

There are two options to working with an outline tree. First is using a UI component that provides tools to set a bookmark or display the outline. Second is an API guide to programmatically read outline items.

Outline API

To navigate an outline tree and print its result.

void PrintIndent(PTBookmark *item) 
{
    int ident = [item GetIndent] - 1;
    for (int i=0; i<ident; ++i) {
    printf("  ");
  }
}
void PrintOutlineTree(PTBookmark *item)
{
    for (; [item IsValid]; item=[item GetNext]) {
        PrintIndent(item);
        if ([item IsOpen]) {
            printf("- %s ACTION -> ", [[item GetTitle] UTF8String]);
        }
        else {
            printf("+ %s ACTION -> ", [[item GetTitle] UTF8String]);
        }
        if ([item HasChildren]) {
            PrintOutlineTree([item GetFirstChild]);
        }
    }
}
PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
PTBookmark *root = [doc GetFirstBookmark];
PrintOutlineTree(root);

Read, add, edit PDF outlines and bookmarks
Full code sample which illustrates how to read and edit existing outline items and create new bookmarks using the high-level API.

linkAbout outline tree

A PDF document may display a document outline on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of Bookmarks (sometimes called outline items), which serve as a "visual table of contents" to display the document's structure to the user.

Each Bookmark has a title that appears on screen, and an Action that specifies what happens when a user clicks on the Bookmark. The typical Action for a user-created Bookmark is to move to another location in the current document — although any Action can be specified.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close