Skip to content

pdfkit: document outline (bookmarks) via AddOutlineItem - #23

Merged
tannevaled merged 1 commit into
mainfrom
outlines
Sep 3, 2026
Merged

pdfkit: document outline (bookmarks) via AddOutlineItem#23
tannevaled merged 1 commit into
mainfrom
outlines

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What

A generated PDF had no outline, so a viewer showed no bookmark sidebar to navigate a document's sections.

How

Document.AddOutlineItem(title, level, pageIndex) records a bookmark; items nest by level (an item deeper than the one before becomes its child), and Write builds the /Outlines tree — each entry a /Title with a /Dest to [page /Fit] plus the /Parent·/Prev·/Next·/First·/Last·/Count links a PDF outline requires. An invalid level or out-of-range page is ignored; a document with no items carries no catalog /Outlines.

Verification

Tests cover a nested tree (section → subsection with a stack unwind back to top level), the sibling/child links, and the ignored-item and no-outline paths. 100% coverage, go vet, gofmt clean.

Enables a bookmark sidebar in go-tex/engine (a follow-up feeds section headings from the engine's TOC entries).

🤖 Generated with Claude Code

A generated PDF had no outline, so a viewer showed no bookmark sidebar to navigate
a document's sections.

Add Document.AddOutlineItem(title, level, pageIndex): items nest by level (an item
deeper than the one before becomes its child) and Write builds the /Outlines tree —
each a /Title with a /Dest to [page /Fit] and the /Parent //Prev //Next //First
//Last //Count links a PDF outline requires. An invalid level or an out-of-range
page is ignored; a document with no items carries no catalog /Outlines.

Tests cover a nested tree (section/subsection with a stack unwind back to top level),
the sibling and child links, and the ignored-item and no-outline paths; 100%
coverage, go vet and gofmt clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit bc1e60c into main Sep 3, 2026
1 check passed
@tannevaled
tannevaled deleted the outlines branch September 3, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant