arun1

arun1

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 ?

Most Liked

arun1

arun1

Thanks to everyone who replied, I ended up choosing Typst. The markdown is pretty powerful and easy to learn. There free online editor makes it easy to experiment with the markdown as well.

I don’t have any data to back this up but figured a rust library would be more performant than weasyprint in python

I could not get ex_typst to work, so I just called the typst compiler using System.cmd.

I have a base .typ file that has the layout and template variables. I use elixir’s EEx to fill out the data and write a .typ file to a temporary location. Finally I execute the typst compiler using the shell.

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.

marceldegraaf

marceldegraaf

@arun1 not sure if you still need a solution here, but in case it helps: we’re using Gotenberg to generate PDF’s from HTML/CSS. We’re running the default Gotenberg Docker image and use the HTTP API to convert rendered Phoenix templates to PDF.

This is especially nice because we can use all the normal view helpers and Tailwind styling that we have throughout our application, and these days things like a table of contents or page numbering is pretty much solved in CSS.

Let me know if you’re interested in some example code of our setup, and the resulting PDF file!

Last Post!

abrookewood

abrookewood

Totally spit balling here, but maybe you could combine an embedded JavaScript runtime (DenoRider - An embedded JavaScript runtime in Elixir - #6 by hubertlepicki) with something like paged.js if you want to do it server-side.

Where Next?

Popular in Questions Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New

We're in Beta

About us Mission Statement