Skip to content

feat(outline): make resolve_named_destination public - #881

Merged
yfedoseev merged 5 commits into
yfedoseev:mainfrom
ajbufort:feat/public-resolve-named-destination
Jul 18, 2026
Merged

feat(outline): make resolve_named_destination public#881
yfedoseev merged 5 commits into
yfedoseev:mainfrom
ajbufort:feat/public-resolve-named-destination

Conversation

@ajbufort

Copy link
Copy Markdown
Contributor

What

Make PdfDocument::resolve_named_destination public (it was pub(crate)), with a
doctest.

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 the
resolver 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
/Dests dict + /Names/Dests name tree itself, duplicating logic that already
lives 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 /Link annotation whose action is GoTo a named dest can be
rendered as an internal page jump.

Change

  • resolve_named_destination(&self, name: &str) -> Result<Option<usize>>:
    pub(crate)pub.
  • Adds a # Example doctest (this repo requires doctests on public items).

No behavior change; purely a visibility + documentation change.

Checklist

  • cargo build
  • cargo clippy -- -D warnings
  • cargo test --doc resolve_named_destination (the new doctest)
  • cargo fmt
  • DCO sign-off

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>
@ajbufort
ajbufort requested a review from yfedoseev as a code owner July 16, 2026 09:49
@yfedoseev
yfedoseev merged commit 3d8a858 into yfedoseev:main Jul 18, 2026
236 checks passed
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.

2 participants