Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/f89aeb328d6c271087f7a0e9c5f996b2 to your computer and use it in GitHub Desktop.
Save anonymous/f89aeb328d6c271087f7a0e9c5f996b2 to your computer and use it in GitHub Desktop.
#mydiv {
background-color: lightblue;
width: 200px;
height: 200px
}
<div id="mydiv">
<img src="/img/logo-white.png" />
<p>text hhhh!</p>
</div>
<br><br>
<h2 id="link"></h2>
html2canvas([document.getElementById('mydiv')], {
onrendered: function(canvas) {
document.body.appendChild(canvas);
var data = canvas.toDataURL('image/png');
// AJAX call to send `data` to a PHP file that creates an image from the dataURI string and saves it to a directory on the server
document.getElementById('link').innerHTML=data;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment