html2canvas error: Uncaught Error: IndexSizeError: DOM Exception 1

前端 未结 4 1788
慢半拍i
慢半拍i 2020-12-19 04:44

I am using html2canvas to convert a div on a canvas. Like this:




        
4条回答
  •  旧时难觅i
    2020-12-19 05:05

    This is the html2canvas bug report.

    I was able to fix the Uncaught Error: IndexSizeError: DOM Exception 1 by patching the html2canvas.js file.

    replace this:

    ctx.drawImage(canvas, bounds.left, bounds.top, bounds.width, bounds.height, 0, 0, bounds.width, bounds.height);
    

    by this:

    var imgData = canvas.getContext("2d").getImageData(bounds.left, bounds.top, bounds.width, bounds.height);
    ctx.putImageData(imgData, 0, 0);
    

提交回复
热议问题