Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.html() not working at all? #2487

Closed
risacher opened this issue Jun 4, 2019 · 14 comments
Closed

.html() not working at all? #2487

risacher opened this issue Jun 4, 2019 · 14 comments

Comments

@risacher
Copy link
Contributor

risacher commented Jun 4, 2019

The .html() method from the html2pdf plugin doesn't work in Chrome or Firefox, at the moment, including the demo in the jspdf source. Page loads, blank PDF generated.

Try: https://cdn.rawgit.com/MrRio/jsPDF/master/examples/html2pdf/showcase_supported_html.html

My own app that uses this method behaves similarly.

@andmaltes
Copy link

The same is happening to me. I have tried using older versions but still the same. Probably some Chrome update?

@risacher
Copy link
Contributor Author

risacher commented Jun 4, 2019

@andmaltes, do you mean older version of jsPDF or of html2canvas? I suspect it's a change to the html2canvas API, but I hadn't considered that it would be a browser thing.

@risacher
Copy link
Contributor Author

risacher commented Jun 4, 2019

@eKoopmans Could use your help on this one, if you have time.

@msarakon
Copy link

msarakon commented Jun 5, 2019

Same problem here, doesn't work on Edge either, so it doesn't seem to be browser-specific at least. The callback function of .html() never gets called.
I also tried using older version of html2canvas with no luck, but the deprecated .addHTML() method from jsPDF v1.4.1 does work (unfortunately, it's not what I need..)

@KevinVanthuyne
Copy link

I encountered this as well. Installing the latest version oh html2canvas was also giving me a blank pdf, downgrading html2canvas to 1.0.0-alpha.12 makes it work again. No clue what changed inbetween these versions that breaks it. Maybe there's a higher version than alpha12 that also works, but i didn't really look into that.

@hakimio
Copy link

hakimio commented Jun 7, 2019

The last correctly working version of html2canvas is RC1. Downgrade to that one and it should work as expected.

@steebwba
Copy link

Is this because the onrendered callback has been replaced with a promise? RC2 of html2canvas added a deprecation warning with that option and has been removed in RC3

@IndigoParadise
Copy link

As @arasabbasi answered in this closed issuehttps://github.com//issues/2479 it might be due to CORS, you nedd to have both libraries (html2canvas and jspdf ) in the same server or folder

@risacher
Copy link
Contributor Author

risacher commented Jun 17, 2019

@IndigoParadise It is definitely not a CORS issue. CORS does not apply to javascript included in a script element the page - as demonstrated by every CDN in existence. Also, as @hakimio points out, downgrading to html2canvas RC1 works fine, even if its hosted elsewhere.

What @steebwba said sounds plausible, but src/modules/html.js:271 sure looks like the current code is already using promises, and if jsPDF is passed a callback in onrendered, it pulls that out of the html2canvas options and invokes it separately.

@IndigoParadise
Copy link

Now i know its because the html2canvas rc2 and 3 do not currently work with jsPDF, try downgrading the version

@lucasmd
Copy link

lucasmd commented Jul 22, 2019

Some news here ?

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

@ninsau
Copy link

ninsau commented Jun 3, 2021

still having an issue with this. went through several docs but pdf generated is still a blank page
const printQr = () => { const input = document.getElementById("downl"); html2canvas(input).then((canvas) => { const imgData = canvas.toDataURL("image/svg"); const pdf = new jsPDF("landscape", "mm", "a4"); pdf.addImage(imgData, "svg", 10, 10, 180, 0); pdf.autoPrint(); pdf.output("dataurlnewwindow"); }); };

@SACHIN5SOS
Copy link

Even I got this issue.. I downgraded to the RC1 version and working fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants