yWorks / jsPDF

JavaScript PDF generation to work with SVG
MIT License
56 stars 23 forks source link

jsPDF does not support html() in IE v11 #34

Closed VKB2612 closed 4 years ago

VKB2612 commented 4 years ago

jsPDF new version (2.1.1) is running fine on all the browsers except IE v11.

Try below link to reproduce the issue. [https://jsbin.com/runaheq/2/edit?html,js,output]

The JS error meesage is "Object doesn't support property or method 'html'". Please check.

Thanks and regards

HackbrettXXX commented 4 years ago

As you can see in the developer console, the html method requires a Promise implementation:

Promise not found. html-Plugin will not work

So in order to make it work in IE11 load a Promise polyfill first.

VKB2612 commented 4 years ago

Hi @HackbrettXXX,

Thanks for your reply. I could see only error message "Object doesn't support property or method 'html'" in the developer console. Anyways now I have added the polyfill. Now there is no error but pdf is not downloaded as well. Could you please check? Link

Note: I am not able to add a zip file having a video demonstrating the issue. It says "Something went really wrong, and we can't process this file" though the file size is just 3 MB

Regards

yGuy commented 4 years ago

Sorry, we won't debug this for you. You will have to come up with a minimal SSCCE if you think this is a bug in jsPDF.

VKB2612 commented 4 years ago

Hi @yGuy , Please find attached html file. Run it in IE v11. No error in developer console but PDF is not generated. It works in FF, Chrome and Edge however. I hope this example suffices. Please let me know what is the issue here.

jsPDFTest.zip

Regards

HackbrettXXX commented 4 years ago

It seems to be an issue with this special polyfill. With a different promise polyfill, it seems to be working.

I tried to debug it with your polyfill, but this is rather difficult since even in the non-minified version of the polyfill the promise part is minified. I'm still not sure if it is an issue of the polyfill you are using or an issue of the html plugin. What I found out is, that one of the promises is lost somewhere in the pipeline so the execution doesn't continue. The plugin does some really crazy stuff like inheriting from Promise and dynamically setting the prototype of promises. The code seems to be fine at first glance, though.

VKB2612 commented 4 years ago

Hi @HackbrettXXX , Thanks for your reply. "With a different promise polyfill, it seems to be working." I tried to run the same html file referring polyfill file you mentioned, I am still seeing the same error. Did it work for you in IE 11? Regards

HackbrettXXX commented 4 years ago

Did you set window.Promise = window.ES6Promise?

VKB2612 commented 4 years ago

Yes, like shown below. Still the same error. Let me know if something else is missing? window.Promise = window.ES6Promise; function run() { var pdf = new jsPDF('p', 'pt', 'a4'); pdf.html(document.body, { callback: function (output) { console.log('1'); pdf.save('outputPDF.pdf'); } }); }

HackbrettXXX commented 4 years ago

You need to set this before you load jspdf.

VKB2612 commented 4 years ago

Hi @HackbrettXXX , Thanks a lot, its working fine now. Regards