Skip to main content

Watermark

Struct Watermark 

Source
pub struct Watermark {
    pub text: Option<String>,
    pub image: Option<Vec<u8>>,
    pub position: (f64, f64),
    pub font_size: f64,
    pub font: String,
    pub color: u32,
    pub opacity: f64,
    pub rotation: f64,
    pub page: Option<usize>,
}
Expand description

水印配置。支持文本水印和图片水印。

Fields§

§text: Option<String>

水印文本(文本水印)。

§image: Option<Vec<u8>>

水印图片数据(图片水印)。

§position: (f64, f64)

位置 (x, y) mm。

§font_size: f64

文本水印字号。

§font: String

文本水印字体。

§color: u32

文本颜色 RGB hex。

§opacity: f64

透明度 0.0(透明)– 1.0(不透明)。默认 0.3。

§rotation: f64

旋转角度(度)。默认 45.0(对角线)。

§page: Option<usize>

目标页码(1-based)。None = 所有页。

Implementations§

Source§

impl Watermark

Source

pub fn text(content: impl Into<String>) -> Self

创建文本水印。

Source

pub fn position(self, x: f64, y: f64) -> Self

设置位置。

Source

pub fn font_size(self, size: f64) -> Self

设置字号。

Source

pub fn opacity(self, opacity: f64) -> Self

设置透明度。

Source

pub fn rotation(self, degrees: f64) -> Self

设置旋转角度。

Source

pub fn page(self, page: usize) -> Self

设置目标页码。

Trait Implementations§

Source§

impl Clone for Watermark

Source§

fn clone(&self) -> Watermark

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 Watermark

Source§

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

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

impl Default for Watermark

Source§

fn default() -> Self

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

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> 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.