pub struct StructTree {
pub root_elements: Vec<StructElement>,
pub role_map: HashMap<String, String>,
}Expand description
The parsed structure tree of a tagged PDF document.
Fields§
§root_elements: Vec<StructElement>Root structure elements.
role_map: HashMap<String, String>Role mapping: custom tag name to standard tag name.
Implementations§
Source§impl StructTree
impl StructTree
Sourcepub fn from_catalog<S: PdfSource>(
catalog_dict: &HashMap<Name, Object>,
store: &ObjectStore<S>,
) -> DocResult<Option<Self>>
pub fn from_catalog<S: PdfSource>( catalog_dict: &HashMap<Name, Object>, store: &ObjectStore<S>, ) -> DocResult<Option<Self>>
Parse the structure tree from the document catalog dictionary.
Returns Ok(None) if the catalog has no /StructTreeRoot entry.
All traversal is iterative using an explicit stack.
Sourcepub fn role_map_name_for<'a>(&'a self, struct_type: &'a str) -> &'a str
pub fn role_map_name_for<'a>(&'a self, struct_type: &'a str) -> &'a str
Resolve a custom structure type to its standard type via the role map.
Returns the mapped standard type if a mapping exists, or the original type name if no mapping is defined.
Corresponds to CPDF_StructTree::GetRoleMapNameFor() in PDFium.
Sourcepub fn get_role_map_name_for<'a>(&'a self, struct_type: &'a str) -> &'a str
pub fn get_role_map_name_for<'a>(&'a self, struct_type: &'a str) -> &'a str
Upstream-aligned alias for role_map_name_for().
Corresponds to CPDF_StructTree::GetRoleMapNameFor() in PDFium.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Returns the number of top-level children in the structure tree.
Corresponds to upstream FPDF_StructTree_CountChildren.
Sourcepub fn struct_tree_count_children(&self) -> usize
pub fn struct_tree_count_children(&self) -> usize
ADR-019 Tier 2 alias for child_count().
Corresponds to upstream FPDF_StructTree_CountChildren.
Sourcepub fn count_children(&self) -> usize
👎Deprecated since 0.1.0: use struct_tree_count_children() — matches upstream FPDF_StructTree_CountChildren
pub fn count_children(&self) -> usize
use struct_tree_count_children() — matches upstream FPDF_StructTree_CountChildren
Deprecated short alias — use struct_tree_count_children()
or child_count() instead.
Sourcepub fn child_at_index(&self, index: usize) -> Option<&StructElement>
pub fn child_at_index(&self, index: usize) -> Option<&StructElement>
Returns the top-level child at the given zero-based index, or None.
Corresponds to upstream FPDF_StructTree_GetChildAtIndex.
Sourcepub fn struct_tree_get_child_at_index(
&self,
index: usize,
) -> Option<&StructElement>
pub fn struct_tree_get_child_at_index( &self, index: usize, ) -> Option<&StructElement>
ADR-019 Tier 2 alias for child_at_index().
Corresponds to upstream FPDF_StructTree_GetChildAtIndex.
Sourcepub fn get_child_at_index(&self, index: usize) -> Option<&StructElement>
👎Deprecated since 0.1.0: use struct_tree_get_child_at_index() — matches upstream FPDF_StructTree_GetChildAtIndex
pub fn get_child_at_index(&self, index: usize) -> Option<&StructElement>
use struct_tree_get_child_at_index() — matches upstream FPDF_StructTree_GetChildAtIndex
Deprecated short alias — use struct_tree_get_child_at_index()
or child_at_index() instead.
Sourcepub fn elements_for_page_ref(&self, page_ref: ObjectId) -> ElementsForPage<'_> ⓘ
pub fn elements_for_page_ref(&self, page_ref: ObjectId) -> ElementsForPage<'_> ⓘ
Iterate over all structure elements that reference the given page object ID.
Equivalent to upstream CPDF_StructTree::LoadPage, which filters the
structure tree to elements that belong to a specific page. This variant
takes the page’s indirect-object ID (the /Pg reference value stored in
each structure element) and performs an iterative depth-first walk of the
entire tree, yielding every element whose page_ref matches.
Use PageStructure::for_page if you need an owned collection instead.
Sourcepub fn elements_for_mcid(&self, mcid: i32) -> Vec<usize>
pub fn elements_for_mcid(&self, mcid: i32) -> Vec<usize>
Returns the indices (into root_elements) of elements whose subtrees reference
the given marked content ID.
Equivalent to calling find_elements_for_mcid with &self.root_elements.
Sourcepub fn get_elements_for_mcid(&self, mcid: i32) -> Vec<usize>
👎Deprecated: use elements_for_mcid() — no public FPDF_StructTree_GetElementsForMcid API
pub fn get_elements_for_mcid(&self, mcid: i32) -> Vec<usize>
use elements_for_mcid() — no public FPDF_StructTree_GetElementsForMcid API
Non-upstream alias — use elements_for_mcid().
Sourcepub fn elements_for_page<'a>(
&'a self,
page_index: usize,
page_ids: &[ObjectId],
) -> ElementsForPage<'a> ⓘ
pub fn elements_for_page<'a>( &'a self, page_index: usize, page_ids: &[ObjectId], ) -> ElementsForPage<'a> ⓘ
Iterate over all structure elements associated with the page at the given zero-based index, resolved against the provided ordered list of page IDs.
page_ids must be ordered so that page_ids[page_index] is the indirect
object ID of the page at that index — the same ordering as returned by
collect_page_ids in rpdfium-page.
Returns an empty iterator if page_index is out of range.
Trait Implementations§
Source§impl Clone for StructTree
impl Clone for StructTree
Source§fn clone(&self) -> StructTree
fn clone(&self) -> StructTree
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more