Skip to main content

Watermark

Struct Watermark 

Source
pub struct Watermark {
    pub text: String,
    pub rotation_deg: f32,
    pub size: f32,
    pub color: Color,
    pub font: FontKey,
}

Fields§

§text: String§rotation_deg: f32

Counter-clockwise rotation in degrees, applied around the body box’s center. 45° (bottom-left to top-right diagonal) matches the conventional “ENTWURF”/“DRAFT” stamp look.

§size: f32§color: Color§font: FontKey

Implementations§

Source§

impl Watermark

Source

pub fn new(text: impl Into<String>) -> Watermark

Examples found in repository?
examples/report.rs (line 56)
42fn main() {
43    let mut doc = Document::new(PageFormat::A4)
44        .margin(Margin::symmetric(56.0, 56.0))
45        .theme(brand_theme())
46        .header(Header::new(20.0, |_ctx| {
47            Text::new("Jahresbericht 2026 \u{2014} Muster GmbH").size(9.0).into()
48        }))
49        .header_visible_from(2)
50        .footer(Footer::new(20.0, |ctx| {
51            Text::new(format!("Seite {} von {}", ctx.page, ctx.total_pages))
52                .size(9.0)
53                .align(Align::Center)
54                .into()
55        }))
56        .watermark(Watermark::new("ENTWURF"));
57
58    // --- cover page -----------------------------------------------------
59    doc.add(Spacer::new(220.0));
60    doc.add(Text::new("Jahresbericht 2026").heading1().align(Align::Center));
61    doc.add(Spacer::new(8.0));
62    doc.add(Text::new("Muster GmbH").align(Align::Center));
63    doc.add(Text::new("vorgelegt am 20. August 2026").muted().align(Align::Center));
64    doc.add(Element::PageBreak);
65
66    // --- content ---------------------------------------------------------
67    doc.add(Text::new("1. Zusammenfassung").heading1());
68    doc.add(Text::new(
69        "Das Geschäftsjahr 2026 war geprägt von stabilem Wachstum in allen \
70         Kernbereichen. Die folgenden Abschnitte fassen die wichtigsten \
71         Kennzahlen und Entwicklungen zusammen.",
72    ));
73    doc.add(Spacer::new(12.0));
74
75    doc.add(Text::new("2. Wichtigste Ereignisse").heading2());
76    doc.add(
77        List::new()
78            .bullet(Text::new("Markteinführung des neuen Produkts im zweiten Quartal"))
79            .bullet(Text::new("Erweiterung des Teams um 12 neue Mitarbeitende"))
80            .bullet(Text::new("Eröffnung eines zweiten Standorts")),
81    );
82    doc.add(Spacer::new(12.0));
83
84    doc.add(Text::new("3. Zeitplan").heading2());
85    doc.add(
86        List::new()
87            .numbered(Text::new("Kickoff und Planung (Januar \u{2013} Februar)"))
88            .numbered(Text::new("Umsetzung Phase 1 (M\u{e4}rz \u{2013} Juni)"))
89            .numbered(Text::new("Umsetzung Phase 2 (Juli \u{2013} Oktober)"))
90            .numbered(Text::new("Abschluss und Auswertung (November \u{2013} Dezember)")),
91    );
92    doc.add(Spacer::new(12.0));
93
94    doc.add(Text::new("3.1 Details").heading3());
95    doc.add(Text::new(
96        "Weitere Details zu den einzelnen Phasen finden sich im Anhang. \
97         Diese Überschrift bleibt dank keep_with_next garantiert mit \
98         diesem Absatz auf derselben Seite zusammen.",
99    ));
100
101    common::write_pdf(&doc, "report.pdf");
102}
Source

pub fn rotation(self, degrees: f32) -> Watermark

Source

pub fn size(self, size: f32) -> Watermark

Source

pub fn color(self, color: Color) -> Watermark

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<(), Error>

Formats the value using the given formatter. 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, <T as TryFrom<U>>::Error>

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.