New to javascript, please help me to render external images in html2canvas script. Do I have to use useCORS? If yes, where? I have tried rendering images from css and html tags too but its not reflecting.
Also console error: Uncaught (in promise) DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
const elm = document.querySelector(".convert");
html2canvas(elm).then(function(canvas) {
document.querySelector(".result");
document.body.appendChild(canvas);
let cvs = document.querySelector("canvas");
let a = document.querySelector(".a");
a.href= cvs.toDataURL();
a.download="example.png";
});
I also had the same problem
html2canvas(this.PrintOrderID.nativeElement, {
scale: 2,
width: mywindow!.innerHeight,
height: mywindow!.innerWidth,
useCORS: true,
allowTaint : true
}).then((canvas) => {
mywindow!.document.body.appendChild(canvas);
})