Skip to main content

StructTree

Struct StructTree 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn child_count(&self) -> usize

Returns the number of top-level children in the structure tree.

Corresponds to upstream FPDF_StructTree_CountChildren.

Source

pub fn struct_tree_count_children(&self) -> usize

ADR-019 Tier 2 alias for child_count().

Corresponds to upstream FPDF_StructTree_CountChildren.

Source

pub fn count_children(&self) -> usize

👎Deprecated since 0.1.0:

use struct_tree_count_children() — matches upstream FPDF_StructTree_CountChildren

Deprecated short alias — use struct_tree_count_children() or child_count() instead.

Source

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.

Source

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.

Source

pub 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

Deprecated short alias — use struct_tree_get_child_at_index() or child_at_index() instead.

Source

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.

Source

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.

Source

pub fn get_elements_for_mcid(&self, mcid: i32) -> Vec<usize>

👎Deprecated:

use elements_for_mcid() — no public FPDF_StructTree_GetElementsForMcid API

Non-upstream alias — use elements_for_mcid().

Source

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

Source§

fn clone(&self) -> StructTree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StructTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more