working on rendering panel with phantomjs

This commit is contained in:
Torkel Ödegaard
2014-08-08 15:53:31 +02:00
parent 8154b4f60d
commit c669f8c612
5 changed files with 64 additions and 1 deletions
BIN
View File
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
var page = require('webpage').create();
var args = require('system').args;
var params = {};
args.forEach(function(arg) {
var parts = arg.split('=');
params[parts[0]] = parts[1];
});
var usage = "url=<url> png=<filename> width=<width> height=<height>";
if (!params.url || !params.png) {
console.log(usage);
phantom.exit();
}
page.viewportSize = {
width: '800',
height: '400'
};
page.open(params.url, function (status) {
console.log('Loading a web page');
setTimeout(function() {
console.log('rendering panel to ' + params.png);
page.render(params.png);
phantom.exit();
}, 2000);
});