Struct wkhtmltopdf::pdf::PdfBuilder[][src]

pub struct PdfBuilder { /* fields omitted */ }

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

Implementations

impl PdfBuilder[src]

pub fn page_size(&mut self, page_size: PageSize) -> &mut PdfBuilder[src]

The paper size of the output document (default A4)

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

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

pub fn orientation(&mut self, orientation: Orientation) -> &mut PdfBuilder[src]

The orientation of the output document (default portrait)

pub fn dpi(&mut self, dpi: u32) -> &mut PdfBuilder[src]

What dpi should we use when printin (default 72)

pub fn image_quality(&mut self, image_quality: u32) -> &mut PdfBuilder[src]

JPEG image compression quality in percentage (default 94)

pub fn title(&mut self, title: &str) -> &mut PdfBuilder[src]

Title of the output document (default none)

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

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.

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

Set a global setting not explicitly supported by the PdfBuilder

Safety

Unsafe because values not supported by wkhtmltopdf can cause undefined behavior

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

Set an object setting not explicitly supported by the PdfBuilder

Safety

Unsafe because values not supported by wkhtmltopdf can cause undefined behavior

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

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

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

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

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

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

pub fn global_settings(&self) -> Result<PdfGlobalSettings>[src]

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

pub fn object_settings(&self) -> Result<PdfObjectSettings>[src]

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

Trait Implementations

impl Clone for PdfBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.