Sources:http://phantomjs.org/
To run: phantomjs test_phantom.js 'http://xyz.com....'
var system = require('system');var args = system.args;var page = require('webpage').create();page.viewportSize = {width:1366, height:768};var url = 'http://phantomjs.org/screen-capture.html';args.forEach(function(arg, i){console.log(i + '--' + arg);});if(args.length===2){ url = args[1];}console.log("--creating pdf for url:-" + url);page.open(url, function(){ setTimeout(function(){ //wait for some time to load dynamic content(s). page.render('test.pdf'); page.render('test.png'); phantom.exit(); }, 2 * 1000);});