Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function to render only a particular element in PhantomJS
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
You can’t perform that action at this time.