0

I'm trying to convert HTML elements to canvas using html2canvas. The HTML elements contain images with external URLs.

While the images are loaded correctly in the HTML, they are not captured by html2canvas. I have tried using useCors: true and allowTaint : true, but the problem persists.

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

For example:

<img src="https://example.in/wp-content/uploads/2023/06/tick-sign.png">

let promises = elementsToCapture.map(element => {  
  return html2canvas(element, {
    scale : 0.7,  
    removeContainer: true,
    useCors : true,
    allowTaint : true
  });
});

The images from external URLs do not get captured in the resulting canvas.

How can I configure html2canvas to capture images from external URLs? What am I missing?

Any suggestions would be helpful!

Maniyan
  • 35
  • 4
  • Does this answer your question? [Tainted canvases may not be exported](https://stackoverflow.com/questions/22710627/tainted-canvases-may-not-be-exported) – Daniel Beck Jun 20 '23 at 20:10

0 Answers0