From 14bf820eedb339718686880aeb4ed0d3010949f5 Mon Sep 17 00:00:00 2001 From: "Anthony J. (Tony) Bufort" Date: Thu, 16 Jul 2026 01:57:05 -0700 Subject: [PATCH] feat(outline): make resolve_named_destination public 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 --- src/outline.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/outline.rs b/src/outline.rs index f94492a69..16e937b6e 100644 --- a/src/outline.rs +++ b/src/outline.rs @@ -200,7 +200,23 @@ impl PdfDocument { /// PDF 1.2+ `/Names` → `/Dests` name tree, ISO 32000-1 §12.3.2.3 / /// §7.9.6) to a 0-based page index. `Ok(None)` when the name is /// genuinely unresolvable (caller keeps [`Destination::Named`]). - pub(crate) fn resolve_named_destination(&self, name: &str) -> Result> { + /// + /// Named destinations are referenced by string from Link/GoTo actions and + /// outline items; a consumer that follows those references needs to turn a + /// name into the page it targets. + /// + /// # Example + /// + /// ```no_run + /// use pdf_oxide::PdfDocument; + /// + /// let doc = PdfDocument::open("doc.pdf")?; + /// if let Some(page) = doc.resolve_named_destination("section.1")? { + /// println!("named destination -> page {page}"); + /// } + /// # Ok::<(), pdf_oxide::error::Error>(()) + /// ``` + pub fn resolve_named_destination(&self, name: &str) -> Result> { let catalog = self.catalog()?; let Some(cat) = catalog.as_dict() else { return Ok(None);