Solution 1 :

I have had the same problem. Ended up pulling the necessary libraries+fonts from Amazon Linux 2 image like followed:

1) Run and enter the docker container for Amazon Linux 2:

docker run -it --rm amazonlinux:2.0.20191217.0

2) Install the necessary tools inside of the docker container, and automatically prepare the necessary dependencies (64-bit based):

mkdir -p /deps
yum install -y yum-utils rpmdevtools
yum install -y libXrender.x86_64 fontconfig.x86_64 freetype.x86_64 libXext.x86_64 libX11.x86_64 expat.x86_64 libxcb.x86_64 libXau.x86_64
yumdownloader libXrender.x86_64 fontconfig.x86_64 freetype.x86_64 libXext.x86_64 libX11.x86_64 expat.x86_64 libxcb.x86_64 libXau.x86_64
rpmdev-extract *rpm
cp /tmp/*/usr/lib64/* /deps
cp -R /tmp/*/etc/fonts /deps/

3) Open a new termial windows and navigate into the PDF lambda folder. Using docker ps command, locate the container id and paste following command:

docker cp <CONTAINER_ID>:/deps/ . && mv deps/* . && rmdir deps

4) Replace the content of <your_lambda_path>/deps/fonts/fonts.conf with this, or provide your own config + font files:


5) Inside your handler you will need to set following to find the font:

process.env['FONTCONFIG_PATH'] = process.env['LAMBDA_TASK_ROOT'] + '/fonts'

After doing so, simply zip your package and deploy as you usually have.

Hope that helps

Solution 2 :

check the repositories below for using wkhtmltopdf under Lambda

Problem :

I have updated the lambda function from nodejs8 to nodejs12.

wkhtmltopdf was working well with the nodejs 8 but now I get this error :

“wkhtmltopdf: error while loading shared libraries: cannot open shared object file: No such file or directory

I have tried to put manually the librairie libXrender into the file project but it doesn’t work.

If someone have the solution on how to make wkhtmltopdf work on aws lambda in nodejs 12 that would be great. Thank you in advance.


Comment posted by akkie

I’ve the same issue. Do you have found a solution in the meantime?

Comment posted by

I had way too many libs with these steps so I took the couple libs that I needed. I had to download font from an instance of Amazon Linux 1. /etc/fonts /usr/share/X11/fonts/Type1 /usr/share/fonts and then it work out. This post help me out alot.

Comment posted by vanessa

The first and the third link used Node.js 4.3. The first link is the one I was using, it was working for nodejs8 but like I said it doesn’t work for nodejs12. The second link just say to download the binary wkhtmltopdf and I had tried that doesn’t work either.

Comment posted by Narendra Chouhan

@vanessa did you find any solution to run the wkhtmltopdf with nodejs12, i am also facing same issue it was working for node8

Comment posted by vanessa

@NarendraChouhan No I didn’t find a solution, i’m working right now on other projects.