wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely “headless” and do not require a display or display service.
Install wkhtmltopdf is very easy
apt-get install wkhtmltopdf
but this version is not headless, we still need install XÂ Server, because headless version is only for static binary,
apt-get install xvfb Xvfb :1 -screen 5 1024x768x8 & export DISPLAY=:1.5
wkhtmltopdf http://localhost:8080/info.php phpinfo.pdf #output is about 1.5M wkhtmltoimage http://localhost:8080/info.php phpinfo.png #output is about 73M