Skip to content

Instantly share code, notes, and snippets.

@kroepke
Forked from trevordixon/renderElement.js
Created June 19, 2013 22:15
Show Gist options
  • Save kroepke/5818620 to your computer and use it in GitHub Desktop.
Save kroepke/5818620 to your computer and use it in GitHub Desktop.
function renderElement(page, selector) {
var prevClipRect = page.clipRect;
page.clipRect = page.evaluate(function(selector) {
return document.querySelector(selector).getBoundingClientRect();
}, selector);
var pic = page.renderBase64('png');
page.clipRect = prevClipRect;
return pic;
}
if (module && module.exports) module.exports = renderElement;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment