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

#1281 in Text processing

Download history 52/week @ 2024-02-26 4/week @ 2024-03-04 23/week @ 2024-03-11 1/week @ 2024-03-18 130/week @ 2024-03-25 15/week @ 2024-04-01

148 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

~32MB
~246K SLoC