我正在将div转换为图像而div正在编写“Gujarati”语言但是当我尝试将此div转换为图像时,正确的输出不会出现。
这是我的代码::
<script type="text/javascript">
function ConverToImage() {
var container1 = document.getElementById('container1');
var img = $('#<%= img.ClientID %>')
var hfData = $('#<%= hfData.ClientID %>')
html2canvas(container1, {
onrendered: function(canvas) {
$('.img_val').val(canvas.toDataURL("image/png"));
img.css("display", "block");
img.attr("src", img_val.value);
hfData.attr('value', img_val.value);
}
});
}
</script>
<div class="senctionLetter" id="container1">
......containing "Gujarati"
</div>
<input type="hidden" id="img_val" class="img_val" />
<input id="btnSave" type="button" value="Generate Image" onclick="ConverToImage();" />
<img id="img" runat="server" src="" alt="" style="display: none" />
<asp:Button ID="btn" runat="server" Style="display: none;" OnClick="imgbtnYes_Click" />
<asp:HiddenField ID="hfData" runat="server" />
答案 0 :(得分:0)
试试这个
html2canvas(container1, {//this line take all inner html tag to convert to canvas from container1 element
在你的html gujarati文本中是直接在container1 div中的松散文本。所以将gujarati文本放在一个div标签中并将此div标签放在container1 div
确保您要转换的元素只有html标记。不是直接文字或宽松文字..
更改你的HTML
<div class="senctionLetter" id="container1">
<div><!-- add one more div tag and add your gujarati line in this div -->
......containing "Gujarati"
</div>
</div>