Navigate PDF outline tree on Server/Desktop

To navigate an outline tree and print its result.

1void PrintIdent(Bookmark item)
2{
3 int ident = item.GetIdent() - 1;
4 for (int i=0; i < ident; ++i) {
5 Console.Write(" ");
6 }
7}
8void PrintOutlineTree(Bookmark item)
9{
10 for (; item.IsValid(); item=item.GetNext()) {
11 PrintIdent(item);
12 Console.Write("{0:s}{1:s} ACTION -> ", (item.IsOpen() ? "- " : "+ "), item.GetTitle());
13 if (item.HasChildren()) {
14 PrintOutlineTree(item.GetFirstChild());
15 }
16 }
17}
18PDFDoc doc = new PDFDoc(filename);
19Bookmark root = doc.GetFirstBookmark();
20PrintOutlineTree(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.

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

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales