Some test text!

Loading...
Guides
Outline tree

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));
            };

            bookmarks.map((root) => {
                printOutlineTree(root, 0);
            });
        });
    });
});

About 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 Outlines, which serve as a "visual table of contents" to display the document's structure to the user.

Each Outline has a title, a Page, and a scroll offset that specifies where an outline will take a user that clicks on the Outline. The typical action for a Outline is to move to another location in the current document — although there is an optional parameter to link to a URL instead.

Expand outlines by default

Pass autoExpandOutlines: true in the WebViewer constructor options.

Webviewer({
    ...,
    fullAPI: true,
    autoExpandOutlines: true,
}, viewerElement).then(instance => {
    // ...
});

Or, use this API to expand outlines.

instance.UI.OutlinesPanel.setDefaultOptions({
    autoExpandOutlines: true,
});

Get the answers you need: Support

Upcoming Webinar: Customer Experience and Retaining Control: Boosting Document Automation and Efficiency in Financial Services | Sept 15, 2022 at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use