-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathrasterise.js
More file actions
29 lines (28 loc) · 832 Bytes
/
rasterise.js
File metadata and controls
29 lines (28 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use strict";
var page = require('webpage').create(),
system = require('system'),
address, output, width;
if (system.args.length < 3 || system.args.length > 4) {
console.log('Usage: rasterize.js URL width filename');
phantom.exit();
} else {
address = system.args[1];
width = system.args[2];
output = system.args[3];
page.viewportSize = { width: width, height: 10 };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address "' + address + '"');
phantom.exit(1);
} else {
page.evaluate(function() {
document.getElementsByTagName("body")[0].className = ""
document.body.bgColor = 'white';
});
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});
}