Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

wkhtmltopdf on alpine hangs forever when --window-status is provided #4026

Closed
leandrosilva opened this issue Jul 28, 2018 · 3 comments
Closed

Comments

@leandrosilva
Copy link

I built an alpine docker image with wkhtmltopdf, doing the following:

FROM alpine:3.8

RUN apk update
RUN apk add --no-cache xvfb ttf-freefont fontconfig dbus
RUN apk add qt5-qtbase-dev wkhtmltopdf --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted

Then I did a little modification on the pdf_c_api.c to convert a simple HTML page to PDF:

wkhtmltopdf_set_object_setting(os, "page", "sample1.html");
wkhtmltopdf_set_object_setting(os, "load.windowStatus", "ready");

And on my HTML page a I have that property set at some point:

window.status = "ready";

I am really used to use the --window-status argument with wkhtmltopdf.exe on Windows with very good success. And this sabe C program compiled with g++ over MINGW64 works just fine. Even a Go version using wkhtmltox.dll works a charm. (What I'm trying to do actually is to create a docker image of this program that is working great on my laptop Windows/MINGW64.)

But for some reason it does not work on that alpine image I just built. My custom pdf_c_api.c program not work, neither the very own wkhtmltopdf. They hang forever. If I remove the parameter load.windowStatus in the C program or the equivalent --window-status argument with wkhtmltopdf, they just work with no problem (save a few warnings you can see below).

/app # wkhtmltopdf --window-status ready sample1.html sample1.pdf
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/xorg/modules/dri)
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/xorg/modules/dri)
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/xorg/modules/dri)
libEGL warning: DRI2: failed to open swrast (search paths /usr/lib/xorg/modules/dri)
Loading page (1/2)
[============================================================] 100%

This is what I'm providing as far as X goes:

Xvfb :0 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &
DISPLAY=:0.0

If you guys can provide any help that will be very appreciated.

Thanks in advance.

@leandrosilva
Copy link
Author

apk add mesa-dri-swrast

It eliminates those "libEGL warning: DRI2: failed to open swrast" messages. Is it recommended to add it to the image? I'm is it really used or is it only part of the whole thing but not necessarily used by wkhtmltopdf?

@leandrosilva
Copy link
Author

In an effort to provide more detail, I tried and run it with --debug-javascript and this one:

/app # wkhtmltopdf --window-status ready --debug-javascript sample1.html sample1.pdf
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Loading page (1/2)
Warning: undefined:0 RangeError: Maximum call stack size exceeded.
Warning: undefined:0 RangeError: Maximum call stack size exceeded.

@Tomsgu
Copy link
Contributor

Tomsgu commented Aug 6, 2018

There is already an issue in wkhtmltopdf/packaging repository. Here: wkhtmltopdf/packaging#2 you can find some information including links to working docker images. But there is no solution at the moment.

@Tomsgu Tomsgu closed this as completed Aug 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants