Qu

pdf.outlines

Builtin index · File I/O

pdf.outlines(src)

Input: src · Output: no output

What it is

The document's bookmark/outline tree, flattened into a Table — one row per entry, depth-first. Columns: index (the row's own position, and the handle parent= below takes), level (Num, 0 for a top-level entry), parent_index (Num, the index of the entry this one is nested under, or -1 for a top-level entry), title (Str), and page_index (Num, one-based, or NaN where the entry's destination is not a direct page reference this reads — a named destination or a non-GoTo action). An empty Table (zero rows), not an error, for a PDF with no outlines.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
pdf.outlines(src)
src Table, Num, or Strnot documented yet
not documented yetThe document's bookmark/outline tree, flattened into a Table — one row per entry, depth-first. Columns: index (the row's own position, and the handle parent= below takes), level (Num, 0 for a top-level entry), parent_index (Num, the index of the entry this one is nested under, or -1 for a top-level entry), title (Str), and page_index (Num, one-based, or NaN where the entry's destination is not a direct page reference this reads — a named destination or a non-GoTo action). An empty Table (zero rows), not an error, for a PDF with no outlines.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

import pdf

doc = pdf.merge(["intro.pdf", "results.pdf"])
doc = pdf.add_bookmark(doc, "Introduction", 1)
doc = pdf.add_bookmark(doc, "Results", 3)
rows = pdf.outlines(doc)
print(rows)  # index, level, parent_index, title, page_index


doc = pdf.add_annotation(doc, 1, type = "Text", rect = [10, 10, 200, 40], text = "draft")
doc = pdf.add_attachment(doc, "notes.txt", "notes.txt")
pdf.write_pages("with_extras.pdf", doc, 1 to pdf.page_count(doc))

not run by the build — this one needs something the repository cannot supply · from file-io

How it works

Bookmarks/outlines -- see qu_pdf::OutlineEntry's doc comment for why the shape is a flat, indexed table rather than a nested structure, and why that same index is what add_bookmark's parent= takes.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.