PDF Manipulation in Javascript in Elixir

I am building a print-on-demand integration that demands the pdf files have certain dimensions for Media and Crop boxes. I have looked around and didn’t manage to find a library to do this kind of manipulation in Elixir. I have found https://pdf-lib.js.org/ which fits my use case perfectly.

How do I use this library in Elixir ? Or am I better off writing a Javascript micro service to handle pdf manipulation ?

Can use poppler, write a C program yourself, query the document and return results

1 Like

I would probably use a port and create a node script which did the pdf creation, then call that script from your port in elixir.

2 Likes

This sounds doable, but will it support all functionalities of node, like installing a separate module with npm ?

You are literally running node as a separate process in the method I described so you can do whatever you want with that node process. You would just write it in such a way that it communicates over stdin/stdout and the elixir port can interact with it. See Port — Elixir v1.12.1 for more.

3 Likes

Thanks Ports seems the way to go.