wkhtmltopdf wkhtmltoimage – Cannot Connect to X Server Solution

10.04source codewkhtmltopdfxorg

I compiled wkhtmltopdf from source on Ubuntu 64bit server 10.04 as described in manual. When I try to convert it exits with an error message:

wkhtmltoimage: cannot connect to X server

There is X server installed but not running.
If I download already built version it is working but sometimes throws "Segmentation fault" exception.

So how to make compiled from source version work?

Best Answer

I think you need to install xvfb (Virtual Framebuffer 'fake' X server):

apt-get install xvfb

Then in the terminal:

xvfb-run wkhtmltoimage --format png --quality 100 --no-debug-javascript --height 800 http://facebook.com/ fb.png