9

I installed Wkhtmltopdf on Alpine Docker with the following command:

apk add --no-cache wkhtmltopdf

However when I try to run wkhtmltopdf I get:

/usr/bin/wkhtmltopdf  "test.html" "test.pdf"
Cannot mix incompatible Qt library (version 0x50c03) with this library (version 0x50c00)
Aborted (core dumped)

How can I fix that?

EDIT:

Seems like the issue is that some other package installs not compatable qt version. Here's my Dockerfile:

RUN apk --no-cache update \
    && apk --no-cache upgrade \
    && apk add --no-cache \
            mysql-client \
            php7-mysqli \
            php7-pdo \
            freetype \
            libpng \
            freetype-dev \
            libpng-dev \
            jpeg-dev \
            libjpeg \
            libjpeg-turbo-dev \
            wget \
            zlib-dev \
            ttf-freefont \
            fontconfig \
            xvfb \
            libxrender-dev \
            gettext \
            gettext-dev \
            libxml2-dev \
            gnu-libiconv-dev \
            autoconf \
            g++ \
            git \
            bash \
            wkhtmltopdf
Lau
  • 3,260
  • 5
  • 16
  • 25
  • 1
    What version of Alpine are you using? I've just tested with 3.9.4 and it works. – norbjd Jun 03 '19 at 11:19
  • 1
    `VERSION_ID=3.9.2` I use php:7.2-fpm-alpine as a base image. Not sure if it's possible to update to 3.9.4 – Lau Jun 03 '19 at 11:34
  • 1
    Could you [edit] your question with this information (in particular the base image)? The problem comes from `php` base image I think, because it works on vanilla Alpine (`alpine:3.9.2`). – norbjd Jun 03 '19 at 11:44
  • 1
    I was told here (https://github.com/mileszs/wicked_pdf/issues/605#issuecomment-499601632) that this works: https://github.com/alloylab/Docker-Alpine-wkhtmltopdf – Unixmonkey Jun 10 '19 at 22:20

1 Answers1

4

You cannot install wkhtmltopdf from alpine repositories starting of 3.15 version https://pkgs.alpinelinux.org/packages?name=wkhtmltopdf&branch=edge&repo=&arch=&maintainer=

If you want to use wkhtmltopdf in the newer alpine (3.17 below). You can copy bin files from other images like https://github.com/Surnet/docker-wkhtmltopdf and install related libraries.

Here is Dockerfile:

FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
FROM php:8.2-fpm-alpine3.17 AS app

# wkhtmltopdf install dependencies
RUN apk add --no-cache \
        libstdc++ \
        libx11 \
        libxrender \
        libxext \
        libssl1.1 \
        ca-certificates \
        fontconfig \
        freetype \
        ttf-droid \
        ttf-freefont \
        ttf-liberation \
        # more fonts
        ;
# wkhtmltopdf copy bins from ext image
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/


# install php extensions, apache/nginx etc.

GetoX
  • 4,225
  • 2
  • 33
  • 30