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 more