简体   繁体   English

创建快照时,Chrome 版本 87 不支持 HTML2CANVAS 的 function canvas.toDataURL("image/png")

[英]Chrome version 87 not supporting function canvas.toDataURL("image/png") of HTML2CANVAS when creating snapshot

HTML2Canvas compatibility issue with Chrome version 87.xxxx. HTML2Canvas 与 Chrome 版本 87.xxxx 的兼容性问题。 I am using HTML2Canvas to convert the HTML to PDF in my js project.我在我的 js 项目中使用 HTML2Canvas 将 HTML 转换为 PDF。 It was working perfectly with Chrome version 86.0.xxxx.它与 Chrome 版本 86.0.xxxx 完美配合。 The issue I noticed is, the rendered text on the canvas partially appeared when making snapshot using snapShotURL = canvas.toDataURL("image/png") and generating pdf with this snapshot in latest version of Chrome (87.0.4280.88) and Opera (version 72.0.3815.400.). The issue I noticed is, the rendered text on the canvas partially appeared when making snapshot using snapShotURL = canvas.toDataURL("image/png") and generating pdf with this snapshot in latest version of Chrome (87.0.4280.88) and Opera (version 72.0.3815.400。)。 Not able to show complete line of input text by wrapping it.无法通过包装显示完整的输入文本行。 So the value in the Input field (textbox) in HTML is not getting reflected into the generated PDF.因此 HTML 的输入字段(文本框)中的值不会反映到生成的 PDF 中。 Long line of input text must be wrapped and should appear entire line of text in generated pdf.输入文本的长行必须换行,并且应该在生成的 pdf 中出现整行文本。

I am using latest html2canvas.js, version tested with: 1.0.0-rc.7.我正在使用最新的 html2canvas.js,测试版本为:1.0.0-rc.7。

Any quick suggestions/support is highly appreciated.非常感谢任何快速的建议/支持。

Below is the code snippet I'm using for this process.下面是我用于此过程的代码片段。

    var totalTime = getTotalTimeSpent();
    sessionStorage.setItem("bsView","H");
html2canvas(document.querySelector("#pageWrap")).then(canvas => {
            snapShotURL = canvas.toDataURL("image/png"); //get's image string
            sessionStorage.setItem("snapShotURLS", snapShotURL);  
});

i was facing the similar issue but couldn't find anything related to it after trying over and over again i finally solved the issue.我遇到了类似的问题,但在反复尝试后找不到任何相关的东西,我终于解决了这个问题。 I upgraded to latest html2canvas library (html2canvas 1.0.0-rc.7 https://html2canvas.hertzen.com ) and it worked.我升级到最新的 html2canvas 库(html2canvas 1.0.0-rc.7 https://html2canvas.hertzen.com )并且它工作。 Note: latest library doesn't support html2canvas().then(function(canvas) {}) try to use注意:最新的库不支持 html2canvas().then(function(canvas) {}) 尝试使用

html2canvas($("#pageWrap")[0], {
    onrendered: function (canvas) {

    }
});

The current version 1.3.2 at html2canvas shows a usage of: html2canvas上的当前版本 1.3.2 显示了以下用法:

html2canvas(document.querySelector("#capture")).then(canvas => {
    document.body.appendChild(canvas)
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM