HTTP Service in Rust to convert HTML to PDF
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
samples
src
templates
.env
.gitignore
Cargo.toml
README.md

README.md

PDF-report generator in Rust

It is built in Rust using the following crates:

  1. Rocket framework as HTTP Server
  2. Handlebars-rust as template engine
  3. wkhtmltopdf command line tool to generate PDF (not a crate)
  4. Utilities: log, rust-ini, uuid

Application workflow is an synchronous call over HTTP and looks like this:

HTTP Route -> Service -> Template Engine -> wkhtmltopdf - PDF

See report template in templates/book-order-report.html.

Sample JSON request looks like this:

{
  "template_name": "book-order-report",
  "user_params": {
    "customer_name": "Frank Smith",
    "address": "Address: Frankfurt am Main, Mainzer str. 100",
    "ordered_books": [
      {
        "book_name": "Getting Things Done: The Art of Stress-Free Productivity. Authors: David Allen",
        "amount": 9.51
      },
      {
        "book_name": "Funky Business - Talent Makes Capital Dance. Authors: Ridderstråle, Nordström",
        "amount": 14.99
      },
      {
        "book_name": "The Rust Programming Language (Manga Guide). Authors: Klabnik, Nichols",
        "amount": 23.99
      }
    ],
    "total": 48.49
  }
}

See more details at this INNOQ article: https://www.innoq.com/de/blog/rust-report-generator/