For the complete documentation index, see llms.txt. This page is also available as Markdown.

Navigate PDF outline tree on Server/Desktop

Requirements

Packages are required for production license. Trial keys have unlimited access to all features.

Demo showcases functionality using WebViewer UI.

Package: Page ManipulationLive demo

The basic code needed to navigate an outline tree and print its result:

void PrintIdent(Bookmark item)
{
  int ident = item.GetIdent() - 1;
  for (int i=0; i < ident; ++i) {
    Console.Write("  ");
  }
}
void PrintOutlineTree(Bookmark item)
{
  for (; item.IsValid(); item=item.GetNext()) {
    PrintIdent(item);
    Console.Write("{0:s}{1:s} ACTION -> ", (item.IsOpen() ? "- " : "+ "), item.GetTitle());
    if (item.HasChildren()) {
      PrintOutlineTree(item.GetFirstChild());
    }
  }
}
PDFDoc doc = new PDFDoc(filename);
Bookmark root = doc.GetFirstBookmark();
PrintOutlineTree(root);
void PrintIndent(Bookmark item) 
{
	int ident = item.GetIndent() - 1;
	for (int i=0; i<ident; ++i) {
    cout << "  ";
  }
}
void PrintOutlineTree(Bookmark item)
{
	for (; item.IsValid(); item=item.GetNext()) {
		PrintIndent(item);
    cout << (item.IsOpen() ? "- " : "+ ") << item.GetTitle() << " ACTION -> ";
		if (item.HasChildren()) {
			PrintOutlineTree(item.GetFirstChild());
		}
	}
}
PDFDoc doc(filename);
Bookmark root = doc.GetFirstBookmark();
PrintOutlineTree(root);

Read, add, edit PDF outlines and bookmarks - Full Sample Full code sample which illustrates how to read and edit existing outline items and create new bookmarks using the high-level API. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB. To use this code, you'll need to download and get started with Server SDK.

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.

Last updated

Was this helpful?