Module wkhtmltox_sys::pdf [] [src]

Convert HTML to PDF

A basic example of using wkhtmltopdf looks like this:

use wkhtmltox_sys::pdf::*;
use std::ffi::CString;

let html = CString::new(r##"<b>foo</b>bar"##).expect("null byte found");
unsafe {
    // Init wkhtmltopdf in graphics-less mode
    if wkhtmltopdf_init(0) != 1 {
        panic!("Init failed");
    }

    let gs = wkhtmltopdf_create_global_settings();
    let converter = wkhtmltopdf_create_converter(gs);

    // Add one or more objects to the converter
    let os = wkhtmltopdf_create_object_settings();
    wkhtmltopdf_add_object(converter, os, html.as_ptr());

    // Perform the conversion
    if wkhtmltopdf_convert(converter) != 1 {
        panic!("Conversion failed");
    } {
        // Read the data into `pdf_buf: Vec<u8>`
        let mut data = std::ptr::null();
        let bytes = wkhtmltopdf_get_output(converter, &mut data) as usize;
        let pdf_buf = std::slice::from_raw_parts(data, bytes);
    }

    wkhtmltopdf_destroy_converter(converter);
    wkhtmltopdf_deinit();
}

Additional documentation:

Enums

wkhtmltopdf_converter
wkhtmltopdf_global_settings
wkhtmltopdf_object_settings

Functions

wkhtmltopdf_add_object
wkhtmltopdf_convert
wkhtmltopdf_create_converter
wkhtmltopdf_create_global_settings
wkhtmltopdf_create_object_settings
wkhtmltopdf_current_phase
wkhtmltopdf_deinit
wkhtmltopdf_destroy_converter
wkhtmltopdf_destroy_global_settings
wkhtmltopdf_destroy_object_settings
wkhtmltopdf_extended_qt
wkhtmltopdf_get_global_setting
wkhtmltopdf_get_object_setting
wkhtmltopdf_get_output
wkhtmltopdf_http_error_code
wkhtmltopdf_init
wkhtmltopdf_phase_count
wkhtmltopdf_phase_description
wkhtmltopdf_progress_string
wkhtmltopdf_set_error_callback
wkhtmltopdf_set_finished_callback
wkhtmltopdf_set_global_setting
wkhtmltopdf_set_object_setting
wkhtmltopdf_set_phase_changed_callback
wkhtmltopdf_set_progress_changed_callback
wkhtmltopdf_set_warning_callback
wkhtmltopdf_version

Type Definitions

wkhtmltopdf_int_callback
wkhtmltopdf_str_callback
wkhtmltopdf_void_callback