feat(outline): make resolve_named_destination public - #881
Merged
yfedoseev merged 5 commits intoJul 18, 2026
Conversation
Named destinations (ISO 32000-1 s12.3.2.3) are referenced by string from Link/GoTo actions and outline items. The resolver from name -> 0-based page index already exists but was pub(crate), so a downstream consumer following those references had to re-walk the /Dests dict + /Names name tree itself. Expose it (with a doctest) so Link-annotation and outline consumers can resolve named targets to pages. Signed-off-by: Anthony J. (Tony) Bufort <ajbufort@ajbconsulting.us>
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
Make
PdfDocument::resolve_named_destinationpublic (it waspub(crate)), with adoctest.
Why
Named destinations (ISO 32000-1 §12.3.2.3 / §7.9.6) are referenced by string from
Link/GoTo actions and outline items. The crate already resolves a name to a 0-based
page index -
get_outline()uses it internally for named outline dests - but theresolver is not reachable, so a downstream consumer that follows link targets (or
wants to resolve a name it obtained some other way) has to re-walk the catalog
/Destsdict +/Names→/Destsname tree itself, duplicating logic that alreadylives here and is tested.
Exposing it lets a consumer turn any named destination into the page it targets with
one call, so e.g. a
/Linkannotation whose action isGoToa named dest can berendered as an internal page jump.
Change
resolve_named_destination(&self, name: &str) -> Result<Option<usize>>:pub(crate)→pub.# Exampledoctest (this repo requires doctests on public items).No behavior change; purely a visibility + documentation change.
Checklist
cargo buildcargo clippy -- -D warningscargo test --doc resolve_named_destination(the new doctest)cargo fmt