Crate wkhtmltopdf [−] [src]
Generate PDFs from HTML safely using wkhtmltopdf
Wkhtmltopdf uses QT Webkit to render HTML for PDF generation. This crate depends on low-level wkhtmltopdf bindings, to provide an ergonomimc API for generating PDFs from URLs, local HTML files, or HTML strings. Installing wkhtmltopdf (currently 0.12.3) is a prerequisite to using this crate.
Example
use wkhtmltopdf::*; let html = r#"<html><body><div>foo</div></body></html>"#; let mut pdf_app = PdfApplication::new().expect("Failed to init PDF application"); let mut pdfout = pdf_app.builder() .orientation(Orientation::Landscape) .margin(Size::Inches(2)) .title("Awesome Foo") .build_from_html(&html) .expect("failed to build pdf"); pdfout.save("foo.pdf").expect("failed to save foo.pdf");
Other examples can be seen in the documentation for
PdfBuilder
methods:
Addtionally, the lowlevel
module provides safe abstractions
that allow full configuration of wkhtmltopdf.
Modules
lowlevel |
Low-level wkhtmltopdf without the raw pointers |
Structs
Margin |
PDF Margins |
PdfApplication |
Structure for initializing the underlying wkhtmltopdf |
PdfBuilder |
High-level builder for generating PDFs (initialized from |
PdfOutput |
Generated PDF output |
Enums
Error |
The error type for wkhtmltopdf generation |
Orientation |
PDF Orientation |
PageSize |
Physical size of the paper |
Size |
Unit-aware sizes |
Type Definitions
Result |
A specialized |