Skip to main content

Document

Struct Document 

Source
pub struct Document { /* private fields */ }
Expand description

The top-level document builder

Implementations§

Source§

impl Document

Source

pub fn new() -> Self

Source

pub fn title(self, t: impl Into<String>) -> Self

Source

pub fn author(self, a: impl Into<String>) -> Self

Source

pub fn subject(self, s: impl Into<String>) -> Self

Source

pub fn keywords(self, k: impl Into<String>) -> Self

Source

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

Set the page that opens first (0-indexed)

Source

pub fn outline(self, outline: Outline) -> Self

Source

pub fn form(self, form: AcroForm) -> Self

Source

pub fn page<F>(self, f: F) -> Self
where F: FnOnce(&mut PageBuilder),

Add an A4 page

Source

pub fn page_sized<F>(self, width: f64, height: f64, f: F) -> Self
where F: FnOnce(&mut PageBuilder),

Add a custom-size page

Add an A4 page with hyperlink annotations

Source

pub fn add_pages(self, builders: Vec<PageBuilder>) -> Self

Add pre-built PageBuilders (from TextFlow or similar)

Source

pub fn watermark(self, w: Watermark) -> Self

Apply a watermark (text stamp) to every page

Source

pub fn header(self, h: HeaderFooter) -> Self

Apply a header template to every page

Source

pub fn footer(self, f: HeaderFooter) -> Self

Apply a footer template to every page

Source

pub fn encrypt(self, e: Encryption) -> Self

Encrypt the document with a password

Source

pub fn signature(self, s: SignatureField) -> Self

Add a digital signature field. Use build_signed() to get the placeholder back.

Source

pub fn build(self) -> Vec<u8>

Build and return the final PDF bytes.

Source

pub fn build_signed(self) -> (Vec<u8>, Vec<SignaturePlaceholder>)

Build and return PDF bytes + signature placeholders. After receiving the bytes you can call placeholder.inject(pdf, pkcs7_der) to embed the real cryptographic signature.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.