Using pdf-fill-form with native dependencies on netlify function

Hello,

I’ve added a netlify function to my gatsby site, the main purpose of the function is to manipulate a pdf adding some text to it, using pdf-fill-form.
This library requires two native tools to be installed cairo and poppler, i can install it locally using brew, but i’m not sure if it possible to have them on the netlify function.
At the moment i use netlify-lambda, with package.json and node_modules in the root of the site, i suppose i need to switch to the zip it and ship it method and use the netlify lambda build command, but i’m not sure if this is the right approach.

Thanks in advance for the help.

Hi, @alexpagnotta. Please keep in mind that Functions are running in AWS Lambda so you are working with the restrictions and requirements of that execution environment.

With that in mind, it sounds like you would like to use binaries external to node (specifically, cairo and poppler). If so, the bundling instructions to achieve this can be found here:

If there are other questions, please let us know. If there are questions additional details are helpful, for example: what you tried and what the results were. If you can link us to code in a public repo, that would be ideal as well (but we realize this isn’t always possible).

Thanks, the guide you provided is probably the right approach.
It’s a little overkill for what i need, so after some researching i found a library that doesn’t have native dependencies (pdf-lib, in case anyone is interested), and it’s working fine.
Thanks again for your help.

1 Like