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: libXrender.so.1: 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.
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:
<fontconfig>
<dir>/var/task/fonts/</dir>
<cachedir>/tmp/fonts-cache/</cachedir>
<config></config>
</fontconfig>
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