TransWikia.com

wkhtmltopdf wkhtmltoimage: cannot connect to X server

Ask Ubuntu Asked on December 17, 2021

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?

2 Answers

I faced the above issue in Ubuntu 18.04

Solved the issue by upgrading the wkhtmltoimage to 0.12.5.1

  1. Download the dep/rpm/exe format from the Github release page link here

  2. In ubuntu

    wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb

    sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb

(link need to replace with your matching version in GitHub release page

Answered by Anand Jose on December 17, 2021

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

Answered by jnbdz on December 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP