Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created September 14, 2012 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save roundrobin/3723726 to your computer and use it in GitHub Desktop.
Save roundrobin/3723726 to your computer and use it in GitHub Desktop.
Phantom.js Script
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
console.log('Usage: rasterize.js URL filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1280, height: 1024 };
page.zoomFactor = 1.1;
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
console.log('Open this address '+address);
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment