Setting a resolution for xvfb-run and wkhtmltopdf / wkhtmltoimage

Tomukas picture Tomukas · Apr 7, 2014 · Viewed 10.6k times · Source

I'm trying desperately to give xvfb-run some resolution arguments to take screenshots of websites with wkhtmltox in different resolutions.

I'm using both xvfb-run and wkhtmltox on CentOS.

xvfb-run --server-args="-screen 0 1024x768x24" wkhtmltoimage http://www.whatismyscreenresolution.com/ /tmp/bla.png

Unfortunately my arguments are not respected by xvfb-run. It has always a resolution of 800x600. What am I doing wrong here?

Thanks for any help!

Answer

johndodo picture johndodo · May 4, 2015

You forgot this option: --use-xserver.

So the whole command is:

xvfb-run --server-args="-screen 0 1024x768x24" wkhtmltoimage --use-xserver http://www.whatismyscreenresolution.com/ /tmp/bla.png

(I tested with wkhtmltopdf, but it should be the same with wkhtmltoimage)