Blank PNG / Tainted canvases may not be exported (not using images)

ε祈祈猫儿з 提交于 2019-12-02 00:24:17
cburgmer

There are two things at work here:

  1. You should wait for rasterizeHTML.drawHTML to finish before expecting anything from the canvas:

    
    rasterizeHTML.drawHTML('<div...', canvas, function () {
        var dataUrl = canvas.toDataURL("image/png");
        console.log(dataUrl);
    });
    
  2. Safari & Webkit cannot read back from the canvas once HTML (actually a SVG) has been drawn there. See https://github.com/cburgmer/rasterizeHTML.js/wiki/Browser-issues#wiki-webkit. A bug has been filed with both Chrome and Safari (again, see the link), but until then Firefox sadly is the only browser that allows you to read form it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!