Jspdf: .html() not working at all?

Created on 4 Jun 2019  路  12Comments  路  Source: MrRio/jsPDF

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.

no-issue-activity

Most helpful comment

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

All 12 comments

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

@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.

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

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..)

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.

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

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

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

@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.

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

Some news here ?

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baluMallisetty picture baluMallisetty  路  4Comments

MaxCodeDE picture MaxCodeDE  路  4Comments

NoFootDancer picture NoFootDancer  路  3Comments

sayo96 picture sayo96  路  3Comments

arulmb0136 picture arulmb0136  路  4Comments