#[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 or was not loaded from bytes.
Trait Implementations§
Source§impl Clone for SaveOptions
impl Clone for SaveOptions
Source§fn clone(&self) -> SaveOptions
fn clone(&self) -> SaveOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SaveOptions
impl Debug for SaveOptions
Source§impl Default for SaveOptions
impl Default for SaveOptions
Source§fn default() -> SaveOptions
fn default() -> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreimpl<T> ParallelSend for T
Source§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.