2017-12-07 15:36:09 +01:00
|
|
|
"use strict";
|
|
|
|
var page = require('webpage').create(),
|
|
|
|
system = require('system'),
|
|
|
|
address, output;
|
2013-03-14 11:56:21 +01:00
|
|
|
|
2017-12-07 15:36:09 +01:00
|
|
|
if (system.args.length < 2) {
|
|
|
|
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
|
|
|
|
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
|
|
|
|
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
|
|
|
|
console.log(' "800px*600px" window, clipped to 800x600');
|
|
|
|
phantom.exit(1);
|
|
|
|
} else {
|
|
|
|
address = system.args[1];
|
|
|
|
output = system.args[2];
|
|
|
|
page.viewportSize = { width: 1280, height: 1024};
|
|
|
|
page.open(address, function (status) {
|
|
|
|
if (status !== 'success') {
|
|
|
|
console.log('Unable to load the address!');
|
|
|
|
phantom.exit(1);
|
|
|
|
} else {
|
|
|
|
window.setTimeout(function () {
|
|
|
|
page.render(output);
|
|
|
|
phantom.exit();
|
|
|
|
}, 200);
|
2013-03-14 11:56:21 +01:00
|
|
|
}
|
2017-12-07 15:36:09 +01:00
|
|
|
});
|
2013-03-14 11:56:21 +01:00
|
|
|
}
|
2016-12-12 15:27:29 +01:00
|
|
|
|