Struct wkhtmltopdf::PdfBuilder [] [src]

pub struct PdfBuilder {
    // some fields omitted
}

High-level builder for generating PDFs (initialized from PdfApplication)

Methods

impl PdfBuilder
[src]

fn page_size(&mut self, page_size: PageSize) -> &mut PdfBuilder

The paper size of the output document (default A4)

fn margin<M: Into<Margin>>(&mut self, margin: M) -> &mut PdfBuilder

Size of the page margins (default 10mm on all sides)

Note: Into<Margin> is also implement for tuples of Margin elements to provide CSS-like shorthand for setting each margin

fn orientation(&mut self, orientation: Orientation) -> &mut PdfBuilder

The orientation of the output document (default portrait)

fn dpi(&mut self, dpi: u32) -> &mut PdfBuilder

What dpi should we use when printin (default 72)

fn image_quality(&mut self, image_quality: u32) -> &mut PdfBuilder

JPEG image compression quality in percentage (default 94)

fn title(&mut self, title: &str) -> &mut PdfBuilder

Title of the output document (default none)

fn outline(&mut self, outline_depth: Option<u32>) -> &mut PdfBuilder

Enabled generating an outline (table of contents) in the sidebar with a specified depth (default 4)

Note: despite being a documented in wkhtmltopdf, the outline depth is not currently configurable due to this upstream issue. However, it can enable and disable the outline, and when the upstream issue is resolved, this method will be updated to also set the outline depth.

unsafe fn global_setting<S: Into<Cow<'static, str>>>(&mut self, name: &'static str, value: S) -> &mut PdfBuilder

Set a global setting not explicitly supported by the PdfBuilder

Unsafe because values not supported by wkhtmltopdf can cause undefined behavior

unsafe fn object_setting<S: Into<Cow<'static, str>>>(&mut self, name: &'static str, value: S) -> &mut PdfBuilder

Set an object setting not explicitly supported by the PdfBuilder

Unsafe because values not supported by wkhtmltopdf can cause undefined behavior

fn build_from_url<'a, 'b>(&'a mut self, url: Url) -> Result<PdfOutput<'b>>

Build a PDF using a URL as the source input

Example

let mut pdf_app = PdfApplication::new().expect("Failed to init PDF application");
let mut pdfout = pdf_app.builder()
       .build_from_url("https://www.rust-lang.org/en-US/".parse().unwrap())
       .expect("failed to build pdf");

This method should be safe if using only safe builder methods, or if usage of unsafe methods (e.g. adding custom settings) is properly handled by wkhtmltopdf

fn build_from_path<'a, 'b, P: AsRef<Path>>(&'a mut self, path: P) -> Result<PdfOutput<'b>>

Build a PDF using the provided HTML from a local file

Example

let mut pdf_app = PdfApplication::new().expect("Failed to init PDF application");
let mut pdfout = pdf_app.builder()
       .build_from_path("/path/to/static/index.html")
       .expect("failed to build pdf");

This method should be safe if using only safe builder methods, or if usage of unsafe methods (e.g. adding custom settings) is properly handled by wkhtmltopdf

fn build_from_html<'a, 'b, S: AsRef<str>>(&'a mut self, html: S) -> Result<PdfOutput<'b>>

Build a PDF using the provided HTML source input

Example

let mut pdf_app = PdfApplication::new().expect("Failed to init PDF application");
let html = r#"foo<b>bar</b>"#;
let mut pdfout = pdf_app.builder()
       .build_from_html(&html)
       .expect("failed to build pdf");

This method should be safe if using only safe builder methods, or if usage of unsafe methods (e.g. adding custom settings) is properly handled by wkhtmltopdf

fn global_settings(&self) -> Result<PdfGlobalSettings>

Use the relevant settings to construct a low-level instance of PdfGlobalSettings

fn object_settings(&self) -> Result<PdfObjectSettings>

Use the relevant settings to construct a low-level instance of PdfObjectSettings

Trait Implementations

impl Clone for PdfBuilder
[src]

fn clone(&self) -> PdfBuilder

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more