Created
July 25, 2012 14:37
-
-
Save trevordixon/3176500 to your computer and use it in GitHub Desktop.
Function to render only a particular element in PhantomJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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