Skip to content

engine: a document's sections become the PDF outline (bookmark sidebar) - #204

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

engine: a document's sections become the PDF outline (bookmark sidebar)#204
tannevaled merged 1 commit into
mainfrom
pdf-outlines

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What

A rendered PDF had no outline, so a viewer offered no bookmark sidebar to jump between sections.

How

The engine already records every sectioning command as a \@tocentry (title, level, and the vertical-list position it fell at). RenderPDF now turns those into go-pdfkit outline items — each at its level, jumping to the page its anchor landed on (pageOfIndex). Captions (kind != "toc") are skipped, so only the section hierarchy becomes bookmarks.

go-pdfkit v0.9.0 provides Document.AddOutlineItem and the /Outlines tree (go-pdfkit/pdfkit#23). Bumps v0.8.0 → v0.9.0.

Verification

End-to-end test: a \section/\subsection document renders a PDF carrying /Outlines with the section titles and /Fit destinations. Full engine suite, go vet, gofmt green; rebased on current main.

Gives go-tex PDFs the navigable bookmark sidebar every real PDF has. (Non-ASCII section titles await a UTF-16BE text-string encoding in go-pdfkit — a follow-up affecting /Title//Author/bookmarks together.)

🤖 Generated with Claude Code

A rendered PDF had no outline, so a viewer offered no bookmark sidebar to jump
between sections. The engine already records every sectioning command as a
\@tocentry (title, level, and the vertical-list position it fell at); RenderPDF
now turns those into go-pdfkit outline items, each at its level and jumping to the
page its anchor landed on (pageOfIndex). Captions (kind != "toc") are skipped, so
only the section hierarchy becomes bookmarks.

go-pdfkit v0.9.0 provides Document.AddOutlineItem and the /Outlines tree; bumps
v0.8.0 -> v0.9.0.

Verified end-to-end: a \section/\subsection document renders a PDF carrying
/Outlines with the section titles and /Fit destinations; full engine suite green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 06213f5 into main Sep 3, 2026
18 checks passed
@tannevaled
tannevaled deleted the pdf-outlines branch September 3, 2026 19:57
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