Reputation: 148
Converting a pretty small HTML-file to PDF takes 2 seconds for my test enviroment (Windows 7). On the production web server the same file (Debian) needs 193 seconds.
The web server is being run with a managed hosting solution. They installed wkhtmltopdf and told me I had to use xvfb-run for it to work:
xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "input_file.html" "output_file.pdf"
Now that I've complained that using this command it takes 193 seconds to generate a simple PDF, they say there is nothing they can do about it. Is that really so?
Edit: Somehow, my managed hosting support solved this after some nudging (now it takes 0.8 seconds). I think they might have recompiled the static wkhtmltopdf binaries or something. I now run wkhtmltopdf without xvfb-run.
Upvotes: 3
Views: 4724
Reputation: 81
wkhtmltopdf is going to be very slow, it is doing software rendering of the image in this case, since there is no GPU available.
An alternative is to go to http://wkhtmltopdf.org and download one of the static images. They can be run in true headless mode, and do not require an X server at all. This is still slow, but it has the advantage of having fewer moving parts.
Upvotes: 1
Reputation: 393567
I assume you could leave the xvfb running
xvfb :1 -screen 0 640x480x16 &
DISPLAY=:1 wkhtmltopdf "input_file1.html" "output_file1.pdf"
DISPLAY=:1 wkhtmltopdf "input_file2.html" "output_file2.pdf"
DISPLAY=:1 wkhtmltopdf "input_file3.html" "output_file3.pdf"
sleep .5
or something before launching wkhtmltopdf
)Upvotes: 2