Showing posts with label phantom js. Show all posts
Showing posts with label phantom js. Show all posts

Sunday, 28 May 2017

Render web page to Image using phantom js

Install phantomjs
$ npm install phantomjs
Create a file github.js with following code
var page = require('webpage').create();
//viewportSize being the actual size of the headless browser
page.viewportSize = { width: 1024, height: 768 };
page.open('http://github.com/', function() {
    page.render('github.png');
    phantom.exit();
});
Pass the file as argument to phantomjs
$ phantomjs github.js
Happy Coding !!
By: saurabh saxena