JSFiddle - React, Tailwind, and code Playground
by gugumetal
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div id="mydiv">
<img src="/img/logo-white.png" />
<p>Teste maroto</p>
</div>
<br><br>
CSS
#mydiv {
background-color: lightblue;
width: 200px;
height: 200px
}
JavaScript
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
}
});