High-level Rust bindings for wkhtmltopdf. This is a wrapper around the low-level binding provided by libwkhtmltox-sys.
Resource | Link
----- | -----
Crate |
Documentation | Cargo docs
Upstream | wkhtmltopdf.org
This crate aims to provide full configuration of wkhtmltopdf with safe, ergonomic Rust. Wkhtmltopdf has several non-obvious limitations (mostly caused by Qt). that make it very easy to cause undefined behavior with the C bindings. Two such limitations that greatly impact the API are:
This crate should make it impossible to break those rules in safe code. If you need parallel PDF generation, you will need to spawn/fork processes to do so. Such an abstraction would be a welcome addition to this crate.
Install wkhtmltopdf 0.12.3 (libs and includes).
TODO: Add platform-relevant instructions to replace these manual install:
- lib/*.so
files to /usr/lib
- include/wkhtmltopdf
dir to /usr/include/wkhtmltopdf
Basic usage looks like this:
```rust let html = r#"
pdfout.save("foo.pdf").expect("failed to save foo.pdf"); println!("generated PDF saved as: foo.pdf"); ```
As long as the includes are installed (e.g. pdf.h
), then it's all cargo:
cargo build
cargo test
Note: tests have to be combined into a single test case because we can only init PdfApplication
once, and it is !Send
/!Sync
.
So the preference going forward will be to test with lots of good examples.
Contributions welcome in the form of issue reports, feature requests, feedback, and/or pull request.