I'm using html2canvas
to convert div
to image/png
. It works fine when there is a text in selected div
but I have an image in it. So when I click the button I can't see the image in created base64
image by html2canvas
.
My codes are like this;
this is my script:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="html2canvas.js"></script>
<script>
$(function(){
$('.savedraft').click(function(){
html2canvas([ document.getElementById('div2image') ],{
onrendered: function(canvas) {
window.open(canvas.toDataURL());
}
});
})
});
</script>
this is my body:
<div class="savedraft">Convert</div>
<div id="div2image" >
<img src="WebSite5/html2canvas-master/tests/assets/image_1.jpg" />
</div>