我使用的是html2canvas.js和mPDF库。
所以myproject进程是html div capture - > base64 / png - > mPDF(img src =“data / ~~~~”)
但是mPDF视图图像质量低。我想要mediumQuality或highQuality。
我使用html2canvas来源
function html2img(){
var canvas ="";
html2canvas($("#SavePart"), {
onrendered: function(canvas) {
// canvas is the final rendered <canvas> element
document.getElementById("theimage").src = canvas.toDataURL();
// console.log(canvas.toDataURL());
// Canvas2Image.saveAsPNG(canvas);
var o_hidden = document.createElement("input");
o_hidden.type = "hidden";
o_hidden.name = "data";
o_hidden.value = canvas.toDataURL();
test.appendChild(o_hidden);
document.test.submit();
}
});
}
mPDF代码
$html.='<img src="data:image/jpg;base64,'.$image_data.'" />';
图像质量如何?