Web SDKv1.0.0

OutlineApi

The Outline panel, headless: the bookmark tree, read whole and edited one bookmark at a time. A bookmark is addressed by its path — the indices that lead to it in the tree get() returns ([0] the first top-level bookmark, [0, 2] its third child). A viewer on the document follows each edit: its panel refreshes, it takes an undo step and fires documentChanged. The panel is described under Document features.

get() needs no feature, but without extract every title is ''. set, add, delete and setTitle need the edit-pages feature and refuse with FEATURE_NOT_LICENSED without it. Each of the four refuses a certified document with INVALID_STATE unless options.invalidateSignatures: no certification level allows bookmark changes.

namespacedoc.outline

Usage

TypeScript
for (const chapter of await doc.outline.get()) {
  console.log(chapter.title, '→ page', chapter.pageIndex);
}
await doc.outline.add('Appendix', doc.pageCount - 1);

Reading

getmethodsince 1.0.0
get(): Promise<OutlineNode[]>
The bookmark tree. Without the extract feature every title is '', so a tree read then and given back to set writes them blank: rename with setTitle. Needs no feature.
Returns Promise<OutlineNode[]> Each { title, pageIndex, children }; pageIndex is null when the bookmark has no page (it only groups children).
  • DOCUMENT_CLOSED — the document has been closed.
TypeScript
const chapters = await doc.outline.get();

Editing

setmethodsince 1.0.0
set(nodes: OutlineNode[], options?: SignedDocumentOptions): Promise<void>
Replace the whole tree. Keeps only titles, pages and nesting: each bookmark's zoom, color, style, other actions and open state are lost — use add, delete and setTitle for single edits, which change one bookmark and nothing else. Needs the edit-pages feature.
ParameterTypeDescription
nodesOutlineNode[]The whole tree: { title, pageIndex, children } each.
options?SignedDocumentOptions{ invalidateSignatures? }.
Returns Promise<void>
  • FEATURE_NOT_LICENSED — the license lacks edit-pages.
  • PAGE_ERROR — the change could not be written.
  • DOCUMENT_CLOSED — the document has been closed.
  • INVALID_STATE — a certified document, unless options.invalidateSignatures (no certification level allows bookmark changes); or a progressive document still downloading.
TypeScript
await doc.outline.set([
  { title: 'Cover', pageIndex: 0, children: [] },
  { title: 'Terms', pageIndex: 4, children: [{ title: 'Payment', pageIndex: 5, children: [] }] },
]);
addmethodsince 1.0.0
add(title: string, pageIndex: number, options?: AddBookmarkOptions): Promise<number[]>
Add one bookmark, as the last child of the bookmark at options.parentPath (omitted: top level), going to pageIndex. Needs the edit-pages feature.
ParameterTypeDescription
titlestringThe bookmark's title.
pageIndexnumberThe zero-based page it goes to.
options?AddBookmarkOptionsparentPath (a path into get()'s tree; omitted, top level) and invalidateSignatures.
Returns Promise<number[]> The new bookmark's path, for delete() / setTitle().
  • INVALID_ARGUMENT — a page index out of range, or a parentPath that names no bookmark.
  • FEATURE_NOT_LICENSED — the license lacks edit-pages.
  • PAGE_ERROR — the change could not be written.
  • DOCUMENT_CLOSED — the document has been closed.
  • INVALID_STATE — a certified document, unless options.invalidateSignatures (no certification level allows bookmark changes); or a progressive document still downloading.
TypeScript
const path = await doc.outline.add('Appendix', doc.pageCount - 1);
await doc.outline.add('Tables', doc.pageCount - 1, { parentPath: path });
deletemethodsince 1.0.0
delete(path: number[], options?: SignedDocumentOptions): Promise<void>
Delete the bookmark at a path, its children with it. Needs the edit-pages feature.
ParameterTypeDescription
pathnumber[]The bookmark's path into get()'s tree.
options?SignedDocumentOptions{ invalidateSignatures? }.
Returns Promise<void>
  • INVALID_ARGUMENT — a path that names no bookmark.
  • FEATURE_NOT_LICENSED — the license lacks edit-pages.
  • PAGE_ERROR — the change could not be written.
  • DOCUMENT_CLOSED — the document has been closed.
  • INVALID_STATE — a certified document, unless options.invalidateSignatures (no certification level allows bookmark changes); or a progressive document still downloading.
TypeScript
await doc.outline.delete([0, 2]); // the first bookmark's third child
setTitlemethodsince 1.0.0
setTitle(path: number[], title: string, options?: SignedDocumentOptions): Promise<void>
Rename the bookmark at a path, in place. Needs the edit-pages feature.
ParameterTypeDescription
pathnumber[]The bookmark's path into get()'s tree.
titlestringThe new title.
options?SignedDocumentOptions{ invalidateSignatures? }.
Returns Promise<void>
  • INVALID_ARGUMENT — a path that names no bookmark.
  • FEATURE_NOT_LICENSED — the license lacks edit-pages.
  • PAGE_ERROR — the change could not be written.
  • DOCUMENT_CLOSED — the document has been closed.
  • INVALID_STATE — a certified document, unless options.invalidateSignatures (no certification level allows bookmark changes); or a progressive document still downloading.
TypeScript
await doc.outline.setTitle([0], 'Introduction');