<div id="Contents">
<div style="float:left;margin-left:10px;">
<svg></svg>
</div>
<div style="float:left;margin-left:10px;">
<svg></svg>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的HTML代码.我想转换它的画布图像.
html2canvas($("#Contents"), {
onrendered: function(canvas) {
window.open(canvas.toDataURL());
}
});
Run Code Online (Sandbox Code Playgroud)
我使用html2canvas插件将其转换为图像,但它不显示svg.我解决了转换svg tp画布但现在html2canvas无法正常工作
var $to=$("#MainContents").clone();
$($to).children(".box").each(function() {
var svg = ResizeArray[$(this).children(".box-content").children().attr("new-id")-1].svg();
var Thiscanvas = document.createElement("canvas");
Thiscanvas.setAttribute("style", "height:" + 100 + "px;width:" + 100+ "px;");
canvg(Thiscanvas, svg);
$(this).append(Thiscanvas);
});
html2canvas($($to), {
onrendered: function(canvasq) {
var w=window.open(canvasq.toDataURL());
w.print();
}
});
Run Code Online (Sandbox Code Playgroud)
我可以将svg转换为canvas但html2canvas函数无效.
html2canvas($("#Element"), {
onrendered: function(canvasq) {
var w=window.open();
w.document.write("<h3 style='text-align:center;'>"+ReportTitle+"</h3>");
w.document.write("<img width='100%' height:'90%' src='"+canvasq.toDataURL()+"' />");
w.print();
}
});
Run Code Online (Sandbox Code Playgroud)
我想提高canvasq.toDataURL()的质量.有什么方法吗?因为返回数据质量低.