我需要使用html2canvas
将HTML转换为图片。问题是它无法正确显示波斯语(波斯语)文本。我想知道是否有人可以帮我解决它!
#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>
&#13;
答案 0 :(得分:2)
在text-align: left
#target
#target {
width: 160px;
height: 50px;
background: blue;
color: #fff;
padding: 10px;
text-align: left
}
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>
编辑:找到相关主题: