5 releases
0.1.4 | Mar 25, 2024 |
---|---|
0.1.3 | Nov 22, 2023 |
0.1.2 | Nov 5, 2023 |
0.1.1 | Oct 28, 2023 |
0.1.0 | Oct 28, 2023 |
#1385 in Text processing
204 downloads per month
13KB
227 lines
Quill Delta to PDF
Parse and convert Quill's Deltas to PDF documents.
lib.rs
:
Parse and convert Quill's Deltas to PDF documents.
Calling DeltaPdf::new()
will parse the data according to the
Quill Delta specification and return an error if the delta
is invalid or has unsupported attributes.
The following attributes are supported:
- bold
- italic
- header
- list
- image
Only inserts are rendered. Deletes and retains are parsed but ignored.
Example Usage
fn main() -> Result<(), Box<dyn std::error::Error>> {
let default_font = genpdf::fonts::from_files("./fonts", "Inter", None)?;
let mut doc = genpdf::Document::new(default_font);
let test = std::fs::read_to_string("./test.json")?;
let mut delta = quill_delta_pdf::DeltaPdf::new(test)?;
delta.set_image_dir("./images".into());
delta.write_to_pdf(&mut doc)?;
doc.render_to_file("test.pdf")?;
Ok(())
}
This library makes use of genpdf. If you want to customize the look of the PDF file feel free to take a look at their documentation
Dependencies
~25MB
~229K SLoC