对于 html2canvas 字体系列不起作用



在使用html2canvas转换png时,稍后我将在画布上绘制该图像。我在 html 中使用多种字体。但是在转换字体时不适用。所以它看起来不同的字体

function getCanvas() {
form.width(myPageSize).css('max-width', 'none');
return html2canvas(form, {
useCORS: true,
imageTimeout: 2000,
removeContainer: true
});
}

实际问题是在HTML中使用多种字体,因此在转换图像时,字体失败。现在它已修复,现在仅使用单一字体

html2canvas(element, {
onrendered: function (canvas) {
var ctx = canvas.getContext('2d');
ctx.webkitImageSmoothingEnabled = true;
ctx.mozImageSmoothingEnabled = true;
ctx.imageSmoothingEnabled = true;
var img = canvas.toDataURL('image/png');
console.log(img);
}
})

我已经为我的项目尝试了上面的代码,在此代码中,"元素"是您要为其生成图像的 html 元素。

最新更新