eKoopmans / html2pdf.js

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

IE - Object doesn't support property or method 'reduce' #479

Open dellow88 opened 3 years ago

dellow88 commented 3 years ago

Hi, since the dist folder was removed then rawgit updated I have noticed some issues within IE. Initially I was using https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js however following issue @#463 I updated location to https://rawgit.com/eKoopmans/html2pdf.js/master/dist/html2pdf.bundle.min.js and now whenever I try to use html (promise based) an alert is thrown on screen and error in console... JS used: html2pdf().set(opt).from(element).outputPdf().then(function(pdf) {...).save().then( function () {...});

Error thrown Error in function s (https://rawgit.com/eKoopmans/html2pdf.js/master/dist/html2pdf.bundle.min.js:2:683077): Object doesn't support property or method 'reduce' TypeError: Object doesn't support property or method 'reduce'

Any ideas?

smileBeda commented 3 years ago

https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js differs in nothing compared to https://rawgit.com/eKoopmans/html2pdf.js/master/dist/html2pdf.bundle.min.js

There are literally no single bit of difference between the 2 files, so it is not due to the files.

What you are experiencing can be due to HTML element IDs having the same value as JS Variable names.

dellow88 commented 3 years ago

When I used https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js I actually got an error message saying html2pdf is not defined (when using IE )and added a console.log to determine if promise was enabled and it wasn't. Im not saying original src doesnt include es6-promise but it didnt work so as a test I added es6-promise.auto.min.js to head before htm2pdf and that error went away but still got the "reduce" error message.

I haven't updated the web form where this error occurs in months so is there a change to the underlying source has changed which would affect it? I will look into html ID's clashing with JS ID's but seems very unlikely as div's/ fields are auto generated with fairly unique IDs

Thanks

eKoopmans commented 3 years ago

Hi, I'm sorry for any breakages that have occurred. With v0.10 I had to switch to a different bundler (from Rollup to Webpack), that change is the likely cause of your problems.

For the time being I recommend updating your code to point to v0.9.3 - I've put instructions at the top of the readme.