Skip to main content

StampOptions

Struct StampOptions 

Source
#[non_exhaustive]
pub struct StampOptions { pub position: StampPosition, pub margin: f64, pub angle: f64, pub opacity: f32, pub font: StandardFont, pub font_size: f32, pub color: Color, }
Expand description

How a stamp is drawn.

A config struct with Default. #[non_exhaustive] so a field added later is not a major break; fill one in with StampOptions::builder. The three font fields are read by EditDoc::stamp_text only; the rest apply to an image stamp too.

use pdfrum::{Color, StampOptions, StampPosition};

let draft = StampOptions::builder()
    .position(StampPosition::Center)
    .angle(45.0)
    .opacity(0.3)
    .font_size(96.0)
    .color(Color::from_rgb8(200, 0, 0))
    .build();
assert_eq!(draft.margin, 36.0);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§position: StampPosition

Where the stamp’s box sits. StampPosition::Center by default.

§margin: f64

Points between a corner-placed stamp and the crop box’s edges. 36 — half an inch — by default.

§angle: f64

Degrees counter-clockwise, turned about the stamp’s own centre after it is placed. 0 by default.

§opacity: f32

Constant alpha, 0.0 (invisible) to 1.0 (opaque, the default), written as an /ExtGState. Multiplied into StampOptions::color’s own alpha for text.

§font: StandardFont

The face for a text stamp, one of the standard 14 — Helvetica by default. Text is encoded as WinAnsi, so a character outside Latin-1 draws as nothing.

§font_size: f32

The text size in points. 36 by default.

§color: Color

The text colour. Black by default.

Implementations§

Source§

impl StampOptions

Source

pub fn builder() -> StampOptionsBuilder

A builder starting from the defaults.

let options = pdfrum::StampOptions::builder().angle(45.0).build();

Trait Implementations§

Source§

impl Clone for StampOptions

Source§

fn clone(&self) -> StampOptions

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 StampOptions

Source§

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

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

impl Default for StampOptions

Source§

fn default() -> Self

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

impl PartialEq for StampOptions

Source§

fn eq(&self, other: &StampOptions) -> 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 StampOptions

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.