node-webshot icon indicating copy to clipboard operation
node-webshot copied to clipboard

How to use 'takeShotOnCallback' exactly in NODE app

Open hemangmehta opened this issue 9 years ago • 2 comments

I am using high chart in my html page. I want to take screen shot once chart fully loaded. For now i have used 'renderDelay' option. but i want to use takeShotOnCallback for consistancy.

Can anyone help me out how to use takeShotOnCallback exactly. I am not able to find example in doc too.

I am using below options for now. var options = { width: 'all', height: 'all', renderDelay: 5000 };

Thanks, Hemang

hemangmehta avatar Sep 05 '16 07:09 hemangmehta

try the options:

  {
    ...
    takeShotOnCallback: true,
    // Phantom callbacks
    onLoadFinished: function () {
      window.callPhantom('takeShot');
    },
  },

guojindai avatar Nov 09 '16 05:11 guojindai

You may add the takeShotOnCallback to options in such way

var options = {
    width: 'all',
    height: 'all',
    renderDelay: 5000,
    takeShotOnCallback: true
}

In the page that you taking snapshot, you may manually trigger window.callPhantom('takeShot'). So PhantomJS would take a snapshot after renderDelay once it is triggered.

I believe that PhantomJS will inject function as callPhantom function is not default window function. You can use try:catch to handle exception if user views page directly and only trigger it successfully when PhantomJS views the page

songyanho avatar Apr 10 '17 07:04 songyanho