html2pdf.js
html2pdf.js copied to clipboard
Cannot read property 'canvas' of undefined
Hello, im trying a simple test:
this is in my header:
this is my code :
var element = document.getElementById('my-table');
var worker = html2pdf();
var worker = html2pdf().from(element).save();
And constantly get "Cannot read property 'canvas' of undefined
Any idea ?
im having the same issue any luck?
Same issue hare mate. Any luck? How did you solve it?
Found out that it's working on double click. It outputs an error "Uncaught in promise" then downloads the pdf. Weird.
why is this closed? npm install this library and it gives this error. Seems to be an issue
Got the same issue
So i found out that npm install does not install the right stuff... i had to use the cdn version and it works. So something is messed with the dependency tree of the npm published module
I found the promise API worked even on the npm version
const element = document.getElementsByTagName('body')[0]; html2pdf().set({}).from(element).save();
I am getting the same error. I am using:
Any solution to this issue?
Any solutions yet?
I had this exact issue. This working fiddle got me started: https://jsfiddle.net/eKoopmans/z1rupL4c/, using the dependencies copied literally as local deps/scripts. This link came from the README under Known issues/rendering. Also, I had an extra jspdf dependency from previous fiddling. After including the 2 scripts and removing other jspdf script tag, it works as advertised.
this work for me!! define the next function
function addScript(url) {
var script = document.createElement('script');
script.type = 'application/javascript';
script.src = url;
document.head.appendChild(script);
}
and then when your document is ready call it like that
addScript('https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js');