Skip to main content

Document

Struct Document 

Source
pub struct Document {
    pub doc: PdfDocument,
    pub title_font: PdfFontHandle,
    pub code_font: PdfFontHandle,
    pub page_size: PageSize,
    pub title: String,
    /* private fields */
}
Expand description

Container for all the data required to insert elements into the PDF

Fields§

§doc: PdfDocument

The printpdf PDF document

§title_font: PdfFontHandle

The medium weight font handle

§code_font: PdfFontHandle

The regular weight font handle

§page_size: PageSize

Page size

§title: String

Document title

Implementations§

Source§

impl Document

Source

pub fn new( title: String, page_size: PageSize, ) -> Result<Document, Box<dyn Error>>

Initialize the PDF with default dimensions and the required fonts. Also sets the title and the producer in the PDF metadata.

Source

pub fn insert_title_text(&mut self, title: String)

Insert the given title at the top of the PDF

Source

pub fn insert_pem_text(&mut self, pem: String)

Insert the given PEM ciphertext in the bottom half of the page

Source

pub fn insert_qr_code(&mut self, text: String) -> Result<(), Box<dyn Error>>

Insert the QR code of the PEM encoded ciphertext in the top half of the page

Source

pub fn draw_grid(&mut self)

Draw a grid debugging layout issues

Source

pub fn draw_line( &mut self, points: Vec<Point>, thickness: f32, dash_pattern: LineDashPattern, )

Draw a line on the page

Source

pub fn insert_notes_field(&mut self, label: String, skip_line: bool)

Insert the notes field label and placeholder in the PDF

Add the footer at the bottom of the page

Source

pub fn save_to_bytes(self) -> Result<Vec<u8>, Box<dyn Error>>

Build the final PDF and return as bytes

Source

pub fn save_to_writer<W: Write>( self, writer: &mut W, ) -> Result<(), Box<dyn Error>>

Build the final PDF and write to a writer

Source

pub fn create_pdf( self, grid: bool, notes_label: String, skip_notes_line: bool, encrypted: String, ) -> Result<Vec<u8>, Box<dyn Error>>

Build a PaperAge PDF and return its bytes.

§Arguments
  • grid - Whether to draw a debug grid
  • notes_label - Label for the notes/passphrase field
  • skip_notes_line - Whether to omit the notes placeholder line
  • encrypted - The encrypted ciphertext to encode as a QR code and PEM block

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V