Looking for a Prawn-Like PDF Generation Library in Elixir

@infinityfye ex_typst looks really great. Nice to have a NIF which calls the Typst code instead of having to include the binary like I’m doing.

I need to include images in my generated PDF. Looking at the ex_typst docs and source I can’t find a way to do that using ex_typst, so I thought I might as well ask if you know if it’s possible, since you’ve used the library?

I usually just link to it from the template using the image function, and let Typst do all the hard work. It took me a while to fiddle around with paths but if you want a quick hack the priv directory is easily accessible and you can write to it. I wouldn’t do that on public facing apps, using phoenix for example, unless I’ve rigorously configured the static routes not to include those “temp” directories.

Another solution would be to use the image.decode “function” as the last example here

In one instance I found it easy to use packages from the Typst Universe (their package directory) I had used this one “tiaoma – Typst Universe” when working on a logistics project. These ones are rather hard to integrate with ex_typst out of the box as you would need to modify the world struct from the rust side or include the dependency while compiling with rustler.

Sorry for the long rant, I hope this was helpful.

EDIT: When using json. I include the path to the image in the data.

2 Likes

That was super helpful! Thanks a bunch for the elaborate reply. Much appreciated :slight_smile:

1 Like