pub struct StructElem {
pub struct_type: StructType,
pub children: Vec<StructChild>,
pub page: Option<u32>,
pub attributes: HashMap<String, Object>,
pub alt_text: Option<String>,
pub expansion: Option<String>,
pub actual_text: Option<String>,
pub source_role: Option<String>,
}Expand description
A structure element (StructElem) in the structure tree.
According to PDF spec Section 14.7.2, each StructElem has:
/S- Structure type (e.g., /Document, /P, /H1, /Sect)/K- Children (structure elements or marked content references)/P- Parent structure element/Pg- Page containing this element (optional)/A- Attributes (optional)/Alt- Alternate description (optional, per Section 14.9.3)/E- Expansion for abbreviations (optional, per Section 14.9.5)
Fields§
§struct_type: StructTypeStructure type (e.g., “Document”, “P”, “H1”, “Sect”)
children: Vec<StructChild>Child elements (structure elements or content references)
page: Option<u32>Page number this element appears on (if known)
attributes: HashMap<String, Object>Attributes (optional)
alt_text: Option<String>Alternate description for accessibility (optional) Per PDF spec Section 14.9.3, this provides a human-readable description of the element’s content (e.g., formula LaTeX or description)
expansion: Option<String>Expansion for abbreviations (optional) Per PDF spec Section 14.9.5, the /E entry provides the expanded form of an abbreviation or acronym (e.g., “PDF” -> “Portable Document Format”)
actual_text: Option<String>Actual text replacement (optional) Per PDF spec Section 14.9.4, /ActualText provides exact replacement text for structure elements, overriding all descendant content.
source_role: Option<String>Original role name before RoleMap resolution (optional). When a custom structure type (e.g., “Heading1”) is mapped to a standard type (e.g., “H1”) via the RoleMap, this field preserves the original name. None when the element’s /S value is already a standard type.
Implementations§
Source§impl StructElem
impl StructElem
Sourcepub fn new(struct_type: StructType) -> Self
pub fn new(struct_type: StructType) -> Self
Create a new structure element
Sourcepub fn add_child(&mut self, child: StructChild)
pub fn add_child(&mut self, child: StructChild)
Add a child to this structure element