I need to use html2canvas
to convert HTML to image. The problem is that it can't show the Persian(Farsi) text correctly. I wonder if someone can help me to solve it !
#target {
width: 160px;
height: 50px;
background: blue;
color: #fff;
padding: 10px;
}
button {
display: block;
height: 20px;
margin-top: 10px;
margin-bottom: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<script>
window.takeScreenShot = function() {
html2canvas(document.getElementById("target"), {
onrendered: function(canvas) {
document.body.appendChild(canvas);
},
width: 320,
height: 220
});
}
</script>
<div id="target">
این یک متن فارسی است.
</div>
<button onclick="takeScreenShot()">to image</button>