Open anil826 opened 5 years ago
function addScript(url) { var script = document.createElement('script'); script.type = 'application/javascript'; script.src = url; document.head.appendChild(script); } addScript('https://raw.githack.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.js');
Hi @anil826, the console "addScript" method doesn't always work, sorry. Some webpages have protection against injecting your own code, which is essentially what that is doing.
There may be a useful error message immediately after you try to add the script, for instance GitHub says "Refused to load the script... because it violates the following Content Security Policy". There may be others who know of workarounds, but I don't.
If you have access to the HTML itself, it's definitely better to just put the script directly into the code, i.e. this method. I'm also working on setting this library up on CDNJS, but you could use that GitHack URL for now if you need it hosted online. Good luck!
Im getting this error as well and I have loaded the bundled JS directly into the HTML
I have an HTML-5 offline page and I am trying to add the CDN script and create a simple PDF but it keeps throwing an exception: Uncaught ReferenceError: html2pdf is not defined