wkhtmltox_sys/lib.rs
1//! Low-level bindings for wkhtmltopdf and wkhtmltoimage
2//!
3//! These bindings currently depend on libwkhtmltox 0.12.3
4
5/// Convert HTML to PDF
6///
7/// A basic example of using wkhtmltopdf looks like this:
8///
9/// ```
10/// use wkhtmltox_sys::pdf::*;
11/// use std::ffi::CString;
12///
13/// let html = CString::new(r##"<b>foo</b>bar"##).expect("null byte found");
14/// unsafe {
15/// // Init wkhtmltopdf in graphics-less mode
16/// if wkhtmltopdf_init(0) != 1 {
17/// panic!("Init failed");
18/// }
19///
20/// let gs = wkhtmltopdf_create_global_settings();
21/// let converter = wkhtmltopdf_create_converter(gs);
22///
23/// // Add one or more objects to the converter
24/// let os = wkhtmltopdf_create_object_settings();
25/// wkhtmltopdf_add_object(converter, os, html.as_ptr());
26///
27/// // Perform the conversion
28/// if wkhtmltopdf_convert(converter) != 1 {
29/// panic!("Conversion failed");
30/// } {
31/// // Read the data into `pdf_buf: Vec<u8>`
32/// let mut data = std::ptr::null();
33/// let bytes = wkhtmltopdf_get_output(converter, &mut data) as usize;
34/// let _pdf_buf = std::slice::from_raw_parts(data, bytes);
35/// }
36///
37/// wkhtmltopdf_destroy_converter(converter);
38/// wkhtmltopdf_deinit();
39/// }
40/// ```
41///
42/// Additional documentation:
43///
44/// - [Using PDF c-bindings](http://wkhtmltopdf.org/libwkhtmltox/)
45/// - [PDF settings](http://wkhtmltopdf.org/libwkhtmltox/pagesettings.html) or [src](https://github.com/wkhtmltopdf/wkhtmltopdf/blob/4fa8338092ae77a4dd2e97c6e2e5b853e0c3005f/src/lib/pdfsettings.cc)
46/// - [pdf.h bindings](http://wkhtmltopdf.org/libwkhtmltox/pdf_8h.html) or [src](https://github.com/wkhtmltopdf/wkhtmltopdf/blob/master/src/lib/pdf_c_bindings.cc)
47pub mod pdf;
48
49/// Convert HTML to image
50pub mod image;