ParseOptions

Struct ParseOptions 

Source
pub struct ParseOptions {
    pub strict_mode: bool,
    pub recover_from_stream_errors: bool,
    pub ignore_corrupt_streams: bool,
    pub partial_content_allowed: bool,
    pub max_recovery_attempts: usize,
    pub log_recovery_details: bool,
    pub lenient_streams: bool,
    pub max_recovery_bytes: usize,
    pub collect_warnings: bool,
    pub lenient_encoding: bool,
    pub preferred_encoding: Option<EncodingType>,
    pub lenient_syntax: bool,
}
Expand description

Options for parsing PDF files with different levels of strictness

§Example

use oxidize_pdf::parser::ParseOptions;

// Create tolerant options for handling corrupted PDFs
let options = ParseOptions::tolerant();
assert!(!options.strict_mode);
assert!(options.recover_from_stream_errors);

// Create custom options
let custom = ParseOptions {
    strict_mode: false,
    recover_from_stream_errors: true,
    ignore_corrupt_streams: false, // Still report errors but try to recover
    partial_content_allowed: true,
    max_recovery_attempts: 10,     // Try harder to recover
    log_recovery_details: false,   // Quiet recovery
    lenient_streams: true,
    max_recovery_bytes: 5000,
    collect_warnings: true,
    lenient_encoding: true,
    preferred_encoding: None,
    lenient_syntax: true,
};

Fields§

§strict_mode: bool

Strict mode enforces PDF specification compliance (default: true)

§recover_from_stream_errors: bool

Attempt to recover from stream decoding errors (default: false)

When enabled, the parser will try multiple strategies to decode corrupted streams, including:

  • Raw deflate without zlib wrapper
  • Decompression with checksum validation disabled
  • Skipping corrupted header bytes
§ignore_corrupt_streams: bool

Skip corrupted streams instead of failing (default: false)

When enabled, corrupted streams will return empty data instead of causing parsing to fail entirely.

§partial_content_allowed: bool

Allow partial content when full parsing fails (default: false)

§max_recovery_attempts: usize

Maximum number of recovery attempts for corrupted data (default: 3)

§log_recovery_details: bool

Enable detailed logging of recovery attempts (default: false)

Note: Requires the “logging” feature to be enabled

§lenient_streams: bool

Enable lenient parsing for malformed streams with incorrect Length fields

§max_recovery_bytes: usize

Maximum number of bytes to search ahead when recovering from stream errors

§collect_warnings: bool

Collect warnings instead of failing on recoverable errors

§lenient_encoding: bool

Enable lenient character encoding (use replacement characters for invalid sequences)

§preferred_encoding: Option<EncodingType>

Preferred character encoding for text decoding

§lenient_syntax: bool

Enable automatic syntax error recovery

Implementations§

Source§

impl ParseOptions

Source

pub fn strict() -> Self

Create options for strict parsing (default)

Source

pub fn tolerant() -> Self

Create options for tolerant parsing that attempts recovery

Source

pub fn lenient() -> Self

Create lenient parsing options for maximum compatibility (alias for tolerant)

Source

pub fn skip_errors() -> Self

Create options that skip corrupted content

Trait Implementations§

Source§

impl Clone for ParseOptions

Source§

fn clone(&self) -> ParseOptions

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 ParseOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ParseOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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