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: boolStrict mode enforces PDF specification compliance (default: true)
recover_from_stream_errors: boolAttempt 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: boolSkip 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: boolAllow partial content when full parsing fails (default: false)
max_recovery_attempts: usizeMaximum number of recovery attempts for corrupted data (default: 3)
log_recovery_details: boolEnable detailed logging of recovery attempts (default: false)
Note: Requires the “logging” feature to be enabled
lenient_streams: boolEnable lenient parsing for malformed streams with incorrect Length fields
max_recovery_bytes: usizeMaximum number of bytes to search ahead when recovering from stream errors
collect_warnings: boolCollect warnings instead of failing on recoverable errors
lenient_encoding: boolEnable lenient character encoding (use replacement characters for invalid sequences)
preferred_encoding: Option<EncodingType>Preferred character encoding for text decoding
lenient_syntax: boolEnable automatic syntax error recovery
Implementations§
Source§impl ParseOptions
impl ParseOptions
Sourcepub fn lenient() -> Self
pub fn lenient() -> Self
Create lenient parsing options for maximum compatibility (alias for tolerant)
Sourcepub fn skip_errors() -> Self
pub fn skip_errors() -> Self
Create options that skip corrupted content
Trait Implementations§
Source§impl Clone for ParseOptions
impl Clone for ParseOptions
Source§fn clone(&self) -> ParseOptions
fn clone(&self) -> ParseOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseOptions
impl Debug for ParseOptions
Auto Trait Implementations§
impl Freeze for ParseOptions
impl RefUnwindSafe for ParseOptions
impl Send for ParseOptions
impl Sync for ParseOptions
impl Unpin for ParseOptions
impl UnwindSafe for ParseOptions
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().