engine: a document's sections become the PDF outline (bookmark sidebar) - #204
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).RenderPDFnow 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.AddOutlineItemand the/Outlinestree (go-pdfkit/pdfkit#23). Bumps v0.8.0 → v0.9.0.Verification
End-to-end test: a
\section/\subsectiondocument renders a PDF carrying/Outlineswith the section titles and/Fitdestinations. Full engine suite,go vet,gofmtgreen; 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