I am trying to generate a PDF that features a screenshot of my wrapper element, using jsPDF and html2canvas. See code below:
function printMe() {
html2canvas(document.querySelector("#wrapper")).then(canvas => {
var dataURL = canvas.toDataURL();
var doc = new jsPDF();
doc.addImage(dataURL, 'PNG', 20, 20);
doc.save(“test.pdf");
});
}
I receive a security error from toDataURL:
“Unhandled Promise Rejection: SecurityError: The operation is insecure.”
How can I either fix this error or generate a PDF with this screenshot another way? Or, is there a way I could simply force the screenshot to download?