1 var page = require('webpage').create(),
2 system = require('system'),
5 if (system.args.length < 3 || system.args.length > 5) {
6 console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
7 console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
10 address = system.args[1];
11 output = system.args[2];
12 page.viewportSize = { width: 600, height: 600 };
13 if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
14 size = system.args[3].split('*');
15 page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
16 : { format: system.args[3], orientation: 'portrait', margin: '1cm' };
18 if (system.args.length > 4) {
19 page.zoomFactor = system.args[4];
21 page.open(address, function (status) {
22 if (status !== 'success') {
23 console.log('Unable to load the address!');
26 window.setTimeout(function () {