arun1

arun1

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 ?

Showing Posts 1 to 10

gushonorato

gushonorato

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.

mindok

mindok

asianfilm

asianfilm

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.

arun1

arun1 OP

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.

acrolink

acrolink

I find styling in in HTML and CSS then converting to PDF easier. As for generation using Chromium, the best way to do it is by using an AWS Lambda. Handles concurrency of multiple invocations perfectly.

MikeRocke

MikeRocke

Just done whole investigation into this for work (we are a Java house).

If you can avoid it in the first place, that’s the best approach (i.e. let the client print as pdf from their browser and use css3 styling for print media).

I did contemplate the XSL-FO route, but that seems progressively out of fashion, (I believe it’s down to the push for better CSS for printed media).

I also thought about postscript or tex, but that felt just as fiddly.

I would love to hear your results!

D4no0

D4no0

I think not, unless HTML will be page-size aware at some point, using that technology is very limited when it comes to generating more involved PDFs that actually need to follow some page structure.

I’ve used successfully latex for generating some pretty beefy PDFs before, however the way compiler was implemented makes it really hard to work with and it’s really laggy, especially if you have to do multiple passes. The best alternative on the market is mentioned above by @asianfilm, typst.

There is no great integration library in elixir, yet, but this shouldn’t stop you from using the compiler as external dependency.

MikeRocke

MikeRocke

Ah sorry I might’ve missed something. I thought CSS supports page sizing with size CSS at-rule descriptor - CSS | MDN

Unless we are talking different things?

D4no0

D4no0

Very interesting, this is certainly something new.

The main question is: can this be used to do things like displaying the page number at the bottom of every page?

MikeRocke

MikeRocke

Great question! No idea on that one I’m afraid!

Where Next? Top

Trending in Questions Top

itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New

Other Trending Topics Top

aaronrussell
Omni 2.0 is out. Omni is a universal Elixir client for LLM APIs: text generation, tool use, structured output and decisions through one A...
New
dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews