eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.13k stars 1.39k forks source link

Error when trying to use the latest version of jspdf.js #33

Closed delgah closed 7 years ago

delgah commented 7 years ago

Hi @eKoopmans, how are you? When trying to use the latest version of the jspdf.js library I'm getting this error: TypeError: pdf.addImage is not a function

Checking the jspdf.min.js I'm currently using it seems that it was customized by you. Am I right? Also, it seems that many other scripts where added to the same js file.

Is there a way to use the latest versions of jspdf.js and html2canvas.js with html2pdf? If not, can you provide me the jspdf.js (not the min version) file you're using?

What I'm trying to do is to use the setDisplayMode function provided into the jspdf library. For this I think I will need to modify jspdf.js or make an adjustment to html2pdf.js.

Please let me know your thoughts about this.

Many thanks!

eKoopmans commented 7 years ago

Hey @delgah! I'm doing well, you?

Yes, you can use the latest version of jsPDF. I've tested with the latest version and I'm not getting that error. Can you give me an example of it not working (i.e. jsFiddle)?

For a while I was using a custom build of jsPDF which made only one small change: a bugfix for hyperlinks, which weren't working properly. As of jsPDF v1.3.5, that bugfix has been merged into the main dist. I'll update the /vendor/ version to v1.3.5, which I've tested and is working fine.

html2canvas is undergoing some serious revisions right now, but as is I'd recommend sticking with the version in /vendor/ here.

delgah commented 7 years ago

Hi @eKoopmans, I found the error. I was trying to use the jspdf.js located in the root folder of the build instead of the jspdf.min.js located inside /dist folder. It seems that jspdf.js is not completed somehow, because when I switched back to jspdf.min.js, everything worked perfectly.

Thanks for your time!

eKoopmans commented 7 years ago

Ah I see! It looks like jspdf.js at the root level is part of the source, and needs to be combined with the rest of the source (plugins etc.) to be complete. The other file in dist, jspdf.debug.js, is the un-minified version that you can also use.

Are we good to close this issue?

delgah commented 7 years ago

Yes, closing it.

Thanks!