var front = document.getElementById("tcanvas").toDataURL("image/png");

i have used above code for exporting image but i am getting below error :

Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

1 Answers

0
htho On

A Canvas is "tainted" if anything in the canvas is retrieved from a foregin origin.

The section on the limitations in the documentation of html2canvas says: everything that should be rendered needs to be in the same origin.

The origin is basically the left-hand part of the URL:

http://subdomain.domain.tld/somedocument.html
^         ORIGIN          ^

You need to make sure everything you wan to render has the same origin (or left-hand part).