Skip to main content

SaveOptions

Struct SaveOptions 

Source
pub struct SaveOptions {
    pub mode: SaveMode,
    pub keep_original: bool,
    pub remove_security: bool,
    pub subset_new_fonts: bool,
    pub version: Option<PdfVersion>,
    pub id_source: IdSource,
    pub encrypt: Option<Encryption>,
}
Expand description

Everything a save may be asked to do differently.

Fields§

§mode: SaveMode

Whether to append or rewrite.

§keep_original: bool

Keep the original bytes as the file’s prefix. Only an incremental save reads this; clearing it there turns the save into a rewrite that keeps the appended shape.

§remove_security: bool

Drop the security handler and /Encrypt, writing the document in the clear.

Off by default: an encrypted document saves encrypted under its own handler, and opens with the password it was opened with. Setting this is the explicit way to decrypt one on the way out — and it forces a full save, since plaintext cannot be appended behind ciphertext.

Has no effect on an unencrypted document.

§subset_new_fonts: bool

Subset newly embedded fonts, dropping the glyphs no page shows.

Off by default. When set, every font this save writes as a new object and that a show operator on some page draws with is replaced by a subset carrying only the glyphs still used, named ABCDEF+Original after ISO 32000-1 §9.6.4.

What it subsets: a /Type0 font whose descendant is a CIDFontType2 with an embedded /FontFile2. Nothing else — a Type 1 (/FontFile) or OpenType-CFF (/FontFile3, or an OTTO program) font is left alone, and so is a simple TrueType font, whose codes reach glyphs through a cmap the subsetter removes.

What it does not disturb: the character codes on the page, the CIDs they map to, /W, and /ToUnicode. The subsetter renumbers glyphs, and a rewritten /CIDToGIDMap absorbs that renumbering at the one place ISO 32000-1 §9.7.4.2 already provides for it — so no content stream is regenerated, and text extraction over the saved file is unchanged.

A font whose program will not subset, or whose subset would not be smaller, is written unchanged.

§version: Option<PdfVersion>

The version to declare in the header. 1.0 through 1.7 are honoured; anything outside that range, and None, keep the document’s own.

§id_source: IdSource

Where /ID and subset tags come from.

§encrypt: Option<Encryption>

Encrypt an unencrypted document on the way out: AES-256, revision 6, under these passwords and permissions. None leaves the document as it is. A document that is already encrypted cannot be re-keyed here: asking for it is Error::EncryptedSaveUnsupported.

Trait Implementations§

Source§

impl Clone for SaveOptions

Source§

fn clone(&self) -> SaveOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SaveOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SaveOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for SaveOptions

Source§

impl PartialEq for SaveOptions

Source§

fn eq(&self, other: &SaveOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SaveOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.