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: PdfDocumentThe printpdf PDF document
title_font: PdfFontHandleThe medium weight font handle
code_font: PdfFontHandleThe regular weight font handle
page_size: PageSizePage size
title: StringDocument title
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(
title: String,
page_size: PageSize,
) -> Result<Document, Box<dyn Error>>
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.
Sourcepub fn insert_title_text(&mut self, title: String)
pub fn insert_title_text(&mut self, title: String)
Insert the given title at the top of the PDF
Sourcepub fn insert_pem_text(&mut self, pem: String)
pub fn insert_pem_text(&mut self, pem: String)
Insert the given PEM ciphertext in the bottom half of the page
Sourcepub fn insert_qr_code(&mut self, text: String) -> Result<(), Box<dyn Error>>
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
Sourcepub fn draw_line(
&mut self,
points: Vec<Point>,
thickness: f32,
dash_pattern: LineDashPattern,
)
pub fn draw_line( &mut self, points: Vec<Point>, thickness: f32, dash_pattern: LineDashPattern, )
Draw a line on the page
Sourcepub fn insert_notes_field(&mut self, label: String, skip_line: bool)
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
Sourcepub fn save_to_bytes(self) -> Result<Vec<u8>, Box<dyn Error>>
pub fn save_to_bytes(self) -> Result<Vec<u8>, Box<dyn Error>>
Build the final PDF and return as bytes
Sourcepub fn save_to_writer<W: Write>(
self,
writer: &mut W,
) -> Result<(), Box<dyn Error>>
pub fn save_to_writer<W: Write>( self, writer: &mut W, ) -> Result<(), Box<dyn Error>>
Build the final PDF and write to a writer
Sourcepub fn create_pdf(
self,
grid: bool,
notes_label: String,
skip_notes_line: bool,
encrypted: String,
) -> Result<Vec<u8>, Box<dyn Error>>
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 gridnotes_label- Label for the notes/passphrase fieldskip_notes_line- Whether to omit the notes placeholder lineencrypted- The encrypted ciphertext to encode as a QR code and PEM block
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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