Setting a resolution for xvfb-run and wkhtmltopdf / wkhtmltoimage
Asked Answered
L

3

14

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!

Labour answered 7/4, 2014 at 13:23 Comment(0)
P
7

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)

Palsy answered 4/5, 2015 at 12:15 Comment(2)
@kip: It would be helpful if you wrote how exactly it doesn't work for you. Judging by upvotes (and lack of other comments) this solution should work, and it definitely worked for me at the time.Palsy
For future googlers, I tried this and got Xvfb failed to start and I found I needed to include :1 in the server-args: --server-args=":1 -screen 0 1024x768x24"Lordly
T
2

Add a comma between parameters. In your case "-screen 0, 1024x768x24". Let me know if it helped you. Regards, HBK

Tala answered 23/6, 2014 at 12:37 Comment(0)
D
1

Are you running wkhtmltoimage with a patched QT? If your QT version is NOT patched, a lot of features are ignored, including any commands sent from xvfb-run.

you can check your version like so:

/usr/bin/wkhtmltoimage --version

Change the path to wherever you've stored your wkhtmltoimage file. If the returned version doesn't include "patched QT", then that's probably where you should start. You can download a patched QT version from here:

https://wkhtmltopdf.org/downloads.html

Installation of a patched QT version is not too complicated, try a variation of the following (I'm running Ubuntu 20, other distros will need tweaking):

cd ~
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install -f
/usr/local/bin/wkhtmltoimage --version

Best of luck.

Deadlight answered 7/10, 2020 at 16:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.