Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Screen for full document height #33

Open
oltkkol opened this issue Dec 30, 2017 · 2 comments
Open

.Screen for full document height #33

oltkkol opened this issue Dec 30, 2017 · 2 comments

Comments

@oltkkol
Copy link

oltkkol commented Dec 30, 2017

Any chance to use .screen for full loaded document height + width?

@oltkkol
Copy link
Author

oltkkol commented Dec 30, 2017

solution I'd like to add:

this.repl.defineCommand('screentofile', {
  help: 'saves screenshot to given file',
  action: function(fileName) {
    var fullPage = true;

    self.client.send('Page.getLayoutMetrics', function(err, res){
      var metrics = res;
      var width   = Math.ceil( fullPage? metrics.contentSize.width : metrics.layoutViewport.clientWidth );
      var height  = Math.ceil( fullPage? metrics.contentSize.height: metrics.layoutViewport.clientHeight);
      var clip    = {x: 0, y: 0, width, height, scale: 1 };

      self.client.Page.captureScreenshot( { clip }, function(err, res) {
        var binData = Buffer.from(res.data, 'base64');

        fs.writeFile(fileName, binData, function(err) {
          if(err) {
              self.writeLn( err );
          }
        }); 

        self.writeLn(fileName);
      });
    });
  }
});

@sidorares
Copy link
Owner

hi! yes, probably a good feature to add. Similar puppeteer code: /~https://github.com/GoogleChrome/puppeteer/blob/bd73e4b7b814f0a9df97158f9102e486618c6075/lib/Page.js#L678-L690

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants