Meteor wrapper for node-webshot. Uses PhantomJS and Webkit to capture a screenshot of a URL as an image (png, jpg, or pdf).
Add the package to you your project:
meteor add bryanmorgan:webshot
In your server code, call:
webshot(url, filePath, options, callback);
to capture an image of the web page from url
with the given options
and save the image to filePath
.
See node-webshot's options for full configuration settings.
webshot("http://google.com", "/tmp/google.png", function (err) {
// screenshot saved to /tmp/google.png
});
webshot('<html><body>Hello World</body></html>', 'hello_world.png', { siteType:'html' }, function(err) {
// screenshot saved to a relative path ./hello_world.png
});
var fs = Npm.require('fs');
webshot('google.com', function(err, renderStream) {
var file = fs.createWriteStream('google.png', {encoding: 'binary'});
renderStream.on('data', function(data) {
file.write(data.toString('binary'), 'binary');
});
});