pub struct LoadOptions { /* private fields */ }Expand description
Options that control how a PDF document is loaded into memory.
All options have safe defaults:
max_file_bytes:Some(256 MiB)— rejects enormous inputs before allocating the full object graph.lazy_objstm:false— ObjStm streams are decompressed eagerly, but their container streams are dropped immediately after extraction (saves the decompressed container bytes; Phase 2a optimisation).
§Example
ⓘ
let opts = LoadOptions::new()
.max_file_bytes(64 * 1024 * 1024) // 64 MiB hard limit
.lazy_objstm(true); // defer ObjStm extraction
let doc = Document::load_mem_with_options(data, &opts)?;
doc.resolve_pending_object_streams()?; // required when lazy_objstm = trueImplementations§
Source§impl LoadOptions
impl LoadOptions
Sourcepub fn max_file_bytes(self, limit: impl Into<Option<usize>>) -> Self
pub fn max_file_bytes(self, limit: impl Into<Option<usize>>) -> Self
Set the maximum allowed input size in bytes.
Pass None to remove the limit (not recommended in worker-pool contexts).
Sourcepub fn lazy_objstm(self, lazy: bool) -> Self
pub fn lazy_objstm(self, lazy: bool) -> Self
Enable or disable lazy ObjStm decompression.
When true, ObjStm streams are kept compressed in Document::objects
and their IDs accumulate in Document::pending_obj_streams. The caller
must call Document::resolve_pending_object_streams before using the
document.
Trait Implementations§
Source§impl Clone for LoadOptions
impl Clone for LoadOptions
Source§fn clone(&self) -> LoadOptions
fn clone(&self) -> LoadOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LoadOptions
impl Debug for LoadOptions
Auto Trait Implementations§
impl Freeze for LoadOptions
impl RefUnwindSafe for LoadOptions
impl Send for LoadOptions
impl Sync for LoadOptions
impl Unpin for LoadOptions
impl UnsafeUnpin for LoadOptions
impl UnwindSafe for LoadOptions
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().