pub struct MarkedContent { /* private fields */ }Expand description
Marked content builder for Tagged PDF
Implementations§
Source§impl MarkedContent
impl MarkedContent
Sourcepub fn begin_with_mcid(&mut self, tag: &str, mcid: u32) -> Result<&mut Self>
pub fn begin_with_mcid(&mut self, tag: &str, mcid: u32) -> Result<&mut Self>
Begin marked content with properties dictionary (BDC operator)
This is the primary method for Tagged PDF, as it allows specifying the MCID (Marked Content ID) that links content to structure elements.
§Arguments
tag- Structure type tag (e.g., “P”, “H1”, “Figure”)mcid- Marked Content ID linking to structure tree
§Example
use oxidize_pdf::structure::MarkedContent;
let mut mc = MarkedContent::new();
mc.begin_with_mcid("P", 0)?;
// ... add paragraph content ...
mc.end()?;Sourcepub fn begin_with_typed_properties(
&mut self,
tag: &str,
properties: &[MarkedContentProperty],
) -> Result<&mut Self>
pub fn begin_with_typed_properties( &mut self, tag: &str, properties: &[MarkedContentProperty], ) -> Result<&mut Self>
Begin marked content with typed properties (BDC operator)
This is a type-safe alternative to begin_with_properties that uses
an enum for common marked content properties.
§Arguments
tag- Structure type tagproperties- Typed properties (MCID, Lang, ActualText, etc.)
§Example
use oxidize_pdf::structure::{MarkedContent, MarkedContentProperty};
let mut mc = MarkedContent::new();
let props = vec![
MarkedContentProperty::MCID(0),
MarkedContentProperty::Lang("en-US".to_string()),
];
mc.begin_with_typed_properties("P", &props)?;Sourcepub fn begin_with_properties(
&mut self,
tag: &str,
properties: &[(&str, &str)],
) -> Result<&mut Self>
pub fn begin_with_properties( &mut self, tag: &str, properties: &[(&str, &str)], ) -> Result<&mut Self>
Begin marked content with custom properties dictionary
Allows specifying additional properties beyond MCID.
§Arguments
tag- Structure type tagproperties- Dictionary entries as key-value pairs
§Example
use oxidize_pdf::structure::MarkedContent;
let mut mc = MarkedContent::new();
let props = vec![("MCID", "0"), ("Lang", "(en-US)")];
mc.begin_with_properties("P", &props)?;Sourcepub fn end(&mut self) -> Result<&mut Self>
pub fn end(&mut self) -> Result<&mut Self>
End marked content (EMC operator)
Closes the most recently opened marked content section.
§Errors
Returns an error if there are no open marked content sections.
§Example
use oxidize_pdf::structure::MarkedContent;
let mut mc = MarkedContent::new();
mc.begin("P")?;
mc.end()?; // Closes the "P" sectionSourcepub fn has_open_sections(&self) -> bool
pub fn has_open_sections(&self) -> bool
Returns true if there are open marked content sections
Sourcepub fn open_section_count(&self) -> usize
pub fn open_section_count(&self) -> usize
Returns the number of open marked content sections
Sourcepub fn finish(self) -> Result<String>
pub fn finish(self) -> Result<String>
Finishes marked content generation and returns the PDF operators
§Errors
Returns an error if there are still open marked content sections.
§Example
use oxidize_pdf::structure::MarkedContent;
let mut mc = MarkedContent::new();
mc.begin_with_mcid("P", 0)?;
mc.end()?;
let operators = mc.finish()?;
assert!(operators.contains("BMC") || operators.contains("BDC"));
assert!(operators.contains("EMC"));Sourcepub fn operations(&self) -> &str
pub fn operations(&self) -> &str
Returns the operations string without consuming self
Unlike finish(), this does not validate that all sections are closed.
Useful for incremental content generation.
Trait Implementations§
Source§impl Clone for MarkedContent
impl Clone for MarkedContent
Source§fn clone(&self) -> MarkedContent
fn clone(&self) -> MarkedContent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MarkedContent
impl Debug for MarkedContent
Auto Trait Implementations§
impl Freeze for MarkedContent
impl RefUnwindSafe for MarkedContent
impl Send for MarkedContent
impl Sync for MarkedContent
impl Unpin for MarkedContent
impl UnwindSafe for MarkedContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().