Struct pdfium_render::bookmarks::PdfBookmarks
source · [−]pub struct PdfBookmarks<'a> { /* private fields */ }Expand description
The bookmarks contained within a single PdfDocument.
Bookmarks in PDF files form a tree structure, branching out from a top-level root bookmark.
The PdfBookmarks::root() returns the root bookmark in the containing PdfDocument, if any;
use the root’s PdfBookmark::first_child() and PdfBookmark::next_sibling() functions to
traverse the bookmark tree.
To search the tree for a bookmark with a specific title, use the PdfBookmarks::find_first_by_title() and PdfBookmarks::find_all_by_title() functions. To traverse the tree breadth-first, visiting every bookmark in the tree, create an iterator using the PdfBookmarks::iter() function.
Implementations
sourceimpl<'a> PdfBookmarks<'a>
impl<'a> PdfBookmarks<'a>
sourcepub fn root(&self) -> Option<PdfBookmark<'_>>
pub fn root(&self) -> Option<PdfBookmark<'_>>
Returns the root PdfBookmark in the containing PdfDocument, if any.
sourcepub fn find_first_by_title(
&self,
title: &str
) -> Result<PdfBookmark<'_>, PdfiumError>
pub fn find_first_by_title(
&self,
title: &str
) -> Result<PdfBookmark<'_>, PdfiumError>
Returns the first PdfBookmark in the containing PdfDocument that has a title matching
the given string.
Note that bookmarks are not required to have unique titles, so in theory any number of bookmarks could match a given title. This function only ever returns the first. To return all matches, use PdfBookmarks::find_all_by_title().
sourcepub fn find_all_by_title(&self, title: &str) -> Vec<PdfBookmark<'_>>
pub fn find_all_by_title(&self, title: &str) -> Vec<PdfBookmark<'_>>
Returns all PdfBookmark objects in the containing PdfDocument that have a title
matching the given string.
Note that bookmarks are not required to have unique titles, so in theory any number of bookmarks could match a given title. This function returns all matches by performing a complete breadth-first traversal of the entire bookmark tree. To return just the first match, use PdfBookmarks::find_first_by_title().
sourcepub fn iter(&self) -> PdfBookmarksIterator<'_>ⓘNotable traits for PdfBookmarksIterator<'a>impl<'a> Iterator for PdfBookmarksIterator<'a> type Item = PdfBookmark<'a>;
pub fn iter(&self) -> PdfBookmarksIterator<'_>ⓘNotable traits for PdfBookmarksIterator<'a>impl<'a> Iterator for PdfBookmarksIterator<'a> type Item = PdfBookmark<'a>;
Returns a breadth-first iterator over all the PdfBookmark objects in the containing
PdfDocument, starting from the top-level root bookmark.