pub struct ContentParser { /* private fields */ }Expand description
High-level content stream parser.
Converts tokenized content streams into structured ContentOperation values.
This parser handles the operand stack and operator parsing according to PDF specifications.
§Usage
The parser is typically used through its static methods:
use oxidize_pdf::parser::content::ContentParser;
let content = b"q 1 0 0 1 50 50 cm 100 100 200 150 re S Q";
let operations = ContentParser::parse(content)?;Implementations§
Source§impl ContentParser
impl ContentParser
Sourcepub fn parse(content: &[u8]) -> ParseResult<Vec<ContentOperation>>
pub fn parse(content: &[u8]) -> ParseResult<Vec<ContentOperation>>
Parse a content stream into a vector of operators.
This is a convenience method that creates a parser and processes the entire stream.
§Arguments
content- Raw content stream bytes (may be compressed)
§Returns
A vector of parsed ContentOperation values in the order they appear.
§Errors
Returns an error if:
- Invalid operator syntax is encountered
- Operators have incorrect number/type of operands
- Unknown operators are found
§Example
use oxidize_pdf::parser::content::{ContentParser, ContentOperation};
let content = b"BT /F1 12 Tf 100 200 Td (Hello) Tj ET";
let operations = ContentParser::parse(content)?;
assert_eq!(operations.len(), 5);
assert!(matches!(operations[0], ContentOperation::BeginText));Sourcepub fn parse_content(content: &[u8]) -> ParseResult<Vec<ContentOperation>>
pub fn parse_content(content: &[u8]) -> ParseResult<Vec<ContentOperation>>
Parse a content stream into a vector of operators.
This method tokenizes the input and converts it to operations. It handles the PDF postfix notation where operands precede operators.
Auto Trait Implementations§
impl Freeze for ContentParser
impl RefUnwindSafe for ContentParser
impl Send for ContentParser
impl Sync for ContentParser
impl Unpin for ContentParser
impl UnwindSafe for ContentParser
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more