Outlines
An outline is a structured navigation tool for PDF documents, typically displayed in the sidebar or panel of a document reader. It is usually automatically generated based on the headings and chapter information in the document, but can also be manually edited and adjusted. The outline provides a hierarchical structure of the document, making it easier for users to locate and browse content, and allows quick navigation to different parts of the document.
Display Outline
CPDFOutline? rootOutline = await document.getOutlineRoot();Add Outline
CPDFOutline? rootOutline = await document.getOutlineRoot();
if (rootOutline == null){
rootOutline = await document.newOutlineRoot();
}
bool result = await document.addOutline(
parentUuid: rootOutline.uuid,
insertIndex: 0,
title: 'New Outline',
pageIndex: 0
);Edit Outline
bool result = await document.updateOutline(
uuid: outline.uuid,
title: 'Updated Title',
pageIndex: 1
);Delete Outline
bool result = await document.removeOutline(outline.uuid);Move Outline
The moveOutline method is used to reposition an existing outline node within the document's outline tree. This method moves the target node under the new parent node newParent and inserts it at the position specified by insertIndex, thereby changing the hierarchical relationship and adjusting the order among siblings.
bool result = await document.moveOutline(
outline: outlineToMove, // The outline node to be moved (target node)
newParent: targetParentOutline, // The new parent node. After moving, outline will exist as a child node of newParent
insertIndex: 0, // Insert position in the child node list of newParent, -1 means append to the end
);