无法在'HTMLCanvasElement'上执行'toDataURL':在s3存储桶上设置cors起源后,可能无法导出被污染的画布的问题

问题描述 投票:0回答:1

在下面的代码中,有一些代码使用html2canvas库将html转换为pdf并下载,但显示错误

已污染的画布可能无法导出

    html2canvas(document.getElementById('compare'), {
            scale: window.devicePixelRatio,
            logging: true,
            allowTaint:true,
            onrendered: function (canvas) {
                var data = canvas.toDataURL();
                var docDefinition = {
                    content: [{
                        image: data,
                        width: 500,
                    }]
                };
                //window.open().document.write('<img src="'+data+'"/>');
                setTimeout(function () {
                    ele[0].style.display = 'flex';
                    ele[1].style.display = 'flex';
                    if (ele1.length > 0) {
                        ele1[0].style.display = 'block';
                    }
                }, 300);
               pdfMake.createPdf(docDefinition).download("compare.pdf");
            }
        });
javascript html5-canvas jspdf html2canvas todataurl
1个回答
0
投票
<img src="path/to/s3.jpg" crossorigin>
© www.soinside.com 2019 - 2024. All rights reserved.