Created
March 14, 2018 19:04
-
-
Save anonymous/f89aeb328d6c271087f7a0e9c5f996b2 to your computer and use it in GitHub Desktop.
(source: https://jsfiddle.net/Sq7hg/2021/)
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
#mydiv { | |
background-color: lightblue; | |
width: 200px; | |
height: 200px | |
} |
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
<div id="mydiv"> | |
<img src="/img/logo-white.png" /> | |
<p>text hhhh!</p> | |
</div> | |
<br><br> | |
<h2 id="link"></h2> | |
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
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