wkhtmltopdf on openSuSE: cannot connect to X server

1.2k views Asked by At

I need wkhtmltopdf on openSuSE. I have installed it via the repository. The version is 0.12.1.

To render HTML with Symfony, I use the KnpSnappyBundle. By rendering a twig template, I got the following error message:

The exit status code '1' says something went wrong:
stderr: "wkhtmltopdf: cannot connect to X server
"
stdout: ""
command: /usr/bin/wkhtmltopdf --lowquality '/tmp/knp_snappy557ee05c6bf5f1.66652130.html' '/srv/www/project/web/pdf/document-1.pdf'.

Is there any way to run wkhtmltopdf on this way without the error? Thanks!

1

There are 1 answers

0
AudioBubble On BEST ANSWER

The solution for openSuSE:

  1. Install xvfb-run (on other *nix-systems maybe "xvfb")
  2. Change in the config part of the bundle (in app/config/config.yml) the binary option from "wkhtmltopdf" to xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf
  3. Check the folder permissions.

For german users: http://www.antondachauer.de/2015/06/19/wkhtmltopdf-unter-opensuse-mit-symfony-knpsnappybundle/