Skip to content

Instantly share code, notes, and snippets.

@itsjavi
Created May 20, 2014 14:16
Show Gist options
  • Select an option

  • Save itsjavi/b3f22505776b097ec914 to your computer and use it in GitHub Desktop.

Select an option

Save itsjavi/b3f22505776b097ec914 to your computer and use it in GitHub Desktop.
Convert an HTML element to a PNG image with html2canvas
// this demo works in http://html2canvas.hertzen.com/examples.html
var $w = window;
html2canvas($('.btn:first').get(0), {
onrendered: function(canvas) {
var win = $w.open();
win.document.write('<img src="'+canvas.toDataURL("image/png")+'"/>');
}
});
// project repo: https://github.com/niklasvh/html2canvas
@renatobenks-zz
Copy link

@itsjavi which version has been used here? update your gist, the API from html2canvas changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment