jeylabs / aws-lambda-poppler-layer

AWS Lambda Poppler Layer
51 stars 28 forks source link

Use Cairo 1.16 #5

Closed mrliptontea closed 3 years ago

mrliptontea commented 3 years ago

Hi,

First of all let me join #2 in saying thank you for this!

Secondly, there is a known bug in Cairo library: https://gitlab.freedesktop.org/cairo/cairo/-/issues/358, which for some PDFs can result in free(): invalid pointer error.

It's present in version 1.17.2 but not in 1.16. There's no later version than 1.17.2 at the moment (although the commit that enabled the bug has been since reverted), so I suggest using 1.16. It's also what's used on alpine linux package:

$ docker run --rm -i -t alpine:edge sh
/ # apk add poppler-utils
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
(1/24) Installing libxau (1.0.9-r0)
(2/24) Installing libbsd (0.10.0-r0)
(3/24) Installing libxdmcp (1.1.3-r0)
(4/24) Installing libxcb (1.14-r1)
(5/24) Installing libx11 (1.6.12-r0)
(6/24) Installing libxext (1.3.4-r0)
(7/24) Installing libxrender (0.9.10-r3)
(8/24) Installing expat (2.2.10-r0)
(9/24) Installing brotli-libs (1.0.9-r2)
(10/24) Installing libbz2 (1.0.8-r1)
(11/24) Installing libpng (1.6.37-r1)
(12/24) Installing freetype (2.10.4-r0)
(13/24) Installing libuuid (2.36-r2)
(14/24) Installing fontconfig (2.13.1-r3)
(15/24) Installing pixman (0.40.0-r2)
(16/24) Installing cairo (1.16.0-r2)            <--
(17/24) Installing lcms2 (2.11-r0)
(18/24) Installing libjpeg-turbo (2.0.5-r1)
(19/24) Installing openjpeg (2.3.1-r5)
(20/24) Installing libgcc (10.2.1_pre0-r2)
(21/24) Installing libstdc++ (10.2.1_pre0-r2)
(22/24) Installing tiff (4.1.0-r0)
(23/24) Installing poppler (20.11.0-r0)
(24/24) Installing poppler-utils (20.11.0-r0)   <--
carasaffi commented 1 year ago

Hi this issue seems to be there with font config. [code 127] pdftocairo: symbol lookup error: /opt/lib/libfontconfig.so.1: undefined symbol: FT_Done_MM_Var. Can you provide a fix for this?

micronaut commented 9 months ago

@carasaffi I was able to resolve the undefined symbol: FT_Done_MM_Var error by adding an environment variable to the Lamda function: LD_PRELOAD = /opt/lib/libfreetype.so.