Some test text!

Outline treekeyboard_arrow_down

Outline tree in documents

To navigate an outline tree and print its result.

WebViewer({ ... }, viewerElement).then(instance => {
    const { docViewer } = instance;
    docViewer.on('documentLoaded', () => {

        const doc = docViewer.getDocument();
        doc.getBookmarks().then((bookmarks) => {

            const printOutlineTree = (item, level) => {
                const indent = '   '.repeat(level);
                const name = item.getName();
                console.log(indent + name);
                item.getChildren().map(b => printOutlineTree(b, level+1));

   => {
                printOutlineTree(root, 0);

linkAbout outline tree

A document may contain a document outline, 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, a Page, and a scroll offset that specifies where a bookmark will take a user that clicks on the Bookmark. The typical action for a Bookmark is to move to another location in the current document — although there is an optional parameter to link to a URL instead.

Get the answers you need: Support


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.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more