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

#1325 in Text processing

Download history 11/week @ 2024-07-30 2/week @ 2024-09-17 13/week @ 2024-09-24

204 downloads per month

MIT/Apache

13KB
227 lines

Quill Delta to PDF

Parse and convert Quill's Deltas to PDF documents.


docs.rs Crates.io

Crates.io


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
~227K SLoC