Wednesday 8 April 2015

convert any html file 2 PNG using PhantomJS


Since PhantomJS is using WebKit, a real layout and rendering engine, it can capture a web page as a screenshot. Because PhantomJS can render anything on the web page, it can be used to convert contents not only in HTML and CSS, but also SVG and Canvas.

Beside PNG format, PhantomJS supports JPEG, GIF, and PDF.

phantomjs rasterize.js tiger.png
~/phantomjs/phantomjs-1.9.0-linux-x86_64/bin/phantomjs ~/phantomjs/phantomjs-1.9.0-linux-x86_64/examples/rasterize.js http://websiteAddress/file.html ~/file.png

No comments:

Post a Comment