PDF generation without Chromium dependency

ChromicPDF seems to be the popular choice for pdf generation at the moment. However, I wanted to get some community input on pdf generation libraries that DO NOT have a dependency on Chromium, puppeteer etc. I am trying to avoid the dev ops overhead of managing these additional dependencies. I would rather just draw out a PDF from scratch.

Libraries I looked into:

elixir-pdf - seems functional for the basic needs.
elixir2pdf - The underlying erlang library erlguten is giving me compilation errors so I could not test this

Does anyone have any other suggestions ?

1 Like

Is generating PDFs on the server strictly required? I always generate PDFs on the client side when possible. The two main reasons are:

  1. I don’t waste CPU cycles and memory on the server with heavy libraries.
  2. JavaScript has better libraries to handle PDF generation on the client side.

I’ve been using paged.js and I’m very happy with the results. It even allows me to show a preview before printing to the client.

If you really need to create PDFs on the server side, the most popular library is PdfGenerator, which uses WKHTML instead of Chrome or Puppeteer.

2 Likes

This thread has quite a few options: Looking for a Prawn-Like PDF Generation Library in Elixir

1 Like

I’ve been using Typst, a Rust library for generating PDFs from markdown. Typst is also a pure functional language such that you can put display logic into functions in a template to keep such logic out of Elixir.

To use the latest version, 0.12, you’ll want to use it on the command line from Elixir. There is an Elixir library that packages the Rust for version 0.3 called ExTypst and a fork that updates it to version 0.9.

3 Likes

Thank you. I did look at PDF generator but unfortunately WKHTML has been archived and is no longer available through brew or asdf. It seems most people are trying to migrate of it.