Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / phantomjs / lib / phantom / examples / rasterize.js
1 var page = require('webpage').create(),
2     system = require('system'),
3     address, output, size;
4
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"');
8     phantom.exit(1);
9 } else {
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' };
17     }
18     if (system.args.length > 4) {
19         page.zoomFactor = system.args[4];
20     }
21     page.open(address, function (status) {
22         if (status !== 'success') {
23             console.log('Unable to load the address!');
24             phantom.exit();
25         } else {
26             window.setTimeout(function () {
27                 page.render(output);
28                 phantom.exit();
29             }, 200);
30         }
31     });
32 }