I've installed webshot package and meteor webshot smart package from: https://github.com/TimHeckel/meteor-webshot
In the directory pacages/webshot/lib/webshot.js there is definition of WEBSHOT object. In the default meteor application I want to use this object to get the snapshot as show in the second step from the link above:
Template.hello.events({
'click input' : function () {
var _image = "myscreenshot.png";
var _res = WEBSHOT.snap("http://google.com", "public/exports~/" + _image, {
screenSize: {
width: 300
, height: 300
}
});
}
});
When I click on the button I have an exception: Uncaught ReferenceError: WEBSHOT is not defined.
Command:
meteor list
show webshot package, where do I need to include this package to get this working?
Hubert OG is right, this package is server-side only.
However, it hasn't been updated in 5 months, so it looks like it's not up to date with the latest "linker" of Meteor which is a feature that appeared in 0.6.5 if I remember well.
You need to git clone the package in your local packages directory. (you may need to "meteor remove" the previous package and "meteor add" the new one). Then modify package.js so that it looks like this :
From Meteor 0.6.5, you need to explicitly specify which symbols from the package are exported to the global namespace, because the package code is executed inside a closure.
I had the same problem so I added a new Meteor wrapper using the latest version of node-webshot: https://atmospherejs.com/bryanmorgan/webshot.
You should be able to get it working using:
And then the same API as node-webshot:
The
WEBSHOT
object is available only on the server side. See this line in package.js.To use it, you need to create a method on the server with
Meteor.methods
, useWEBSHOT
inside it and then call this method from your event handler.