Skip to content

Instantly share code, notes, and snippets.

@hkirsman
Forked from FiloSottile/rasterize.js
Last active December 30, 2015 08:29
Show Gist options
  • Save hkirsman/7803029 to your computer and use it in GitHub Desktop.
Save hkirsman/7803029 to your computer and use it in GitHub Desktop.
Add 4x zoom.
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: 2000, height: 100 };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
page.evaluate(function () {
/* scale the whole body */
document.body.style.webkitTransform = "scale(4)";
document.body.style.webkitTransformOrigin = "0% 0%";
/* fix the body width that overflows out of the viewport */
document.body.style.width = "25%";
});
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