#[non_exhaustive]pub struct SaveOptions { /* private fields */ }Expand description
Options for saving a PDF document.
Default behaviour (per RFC 0001 §1.2): linearize = false,
overwrite = false. save / save_with therefore refuse to
clobber existing files unless you opt in via
with_overwrite(true).
§Determinism
For an unencrypted document, save, save_with, to_bytes, and
write_to produce byte-identical output for byte-identical input
(issue #1308). This is enforced by integration tests in
tests/determinism.rs and is part of the 1.0 contract.
Specifically guaranteed:
- Object ordering is sorted by
(id, generation)—BTreeMapin lopdf. - Dictionary key order is preserved on round-trip —
IndexMapin lopdf. - Stream content is copied as-is.
- The cross-reference table is derived deterministically.
NOT deterministic (by design):
- Encrypted output — AES IVs and content keys are randomly generated per save (security requirement, ISO 32000-2 §7.6). Two saves of the same encrypted document produce different bytes.
- Caller-introduced timestamps — anything you write via
metadata_mut()using the system clock (e.g.set_creation_date(SystemTime::now())).
Customer CI pipelines that compare PDF checksums depend on this guarantee — break it only with a new RFC.
Implementations§
Source§impl SaveOptions
impl SaveOptions
Sourcepub fn with_linearize(self, v: bool) -> Self
pub fn with_linearize(self, v: bool) -> Self
Linearize the output for fast web view.
§1.0 behaviour
In 1.0 this flag is accepted but currently a no-op. A true linearizer lands in 1.1. Use it to make your code forward-compatible without waiting for the feature.
Sourcepub fn with_overwrite(self, v: bool) -> Self
pub fn with_overwrite(self, v: bool) -> Self
Permit overwriting an existing file at the target path.
Default is false per RFC 0001 §1.2: save / save_with refuse
to clobber an existing file unless you opt in here. This protects
against accidental overwrites of either the source file or
unrelated files.
Sourcepub fn with_incremental(self, v: bool) -> Self
pub fn with_incremental(self, v: bool) -> Self
Enable incremental save.
When set to true, only changes made to the PDF will be appended to the original file. This preserves signatures and avoids rewriting the entire file. Returns an error if the document is encrypted, was not loaded from bytes, or has been redacted since it was loaded: the original revision an incremental save keeps still holds what the redaction removed.
Trait Implementations§
Source§impl Clone for SaveOptions
impl Clone for SaveOptions
Source§impl Debug for SaveOptions
impl Debug for SaveOptions
Auto Trait Implementations§
impl Freeze for SaveOptions
impl RefUnwindSafe for SaveOptions
impl Send for SaveOptions
impl Sync for SaveOptions
impl Unpin for SaveOptions
impl UnsafeUnpin for SaveOptions
impl UnwindSafe for SaveOptions
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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().Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.