Fix PDF viewer failing on Edge (not based on Chromium) #297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since version v2.4.456 the PDF.js library is published as two different packages, a non-translated/non-polyfilled build for modern browsers and an ES5 compatible build for older browsers.
The PDF viewer was using the build for modern browsers, so it did not work, for example, on Edge (the original version not based on Chromium). This has been changed to use the ES5 build instead for maximum compatibility.
Unfortunately, the ES5 build requires allowing "unsafe-eval" in the iframe where the PDF.js library is loaded :-( Note that we had to fight this already in the past, but back then we just stayed on a version that happened to work. Now it seems that we either allow
unsafe-eval
in the iframe or we drop support for browser that are not compatible with the default PDF.js build (if we want to stay on an updated version, which we of course do ;-) ). See issue 11036 in https://github.com/mozilla/pdf.js/issues (not linked directly to avoid polluting the issue with more back references) for more information.An even more unfortunate part of the history is that I found out that PDF.js provides an ES5 compatible package after wasting hours fighting with Babel, Webpack and so on 🤦 I am so frustrated right now :-P
How to test
Result with this pull request
The PDF file is shown.
Result without this pull request
The PDF file is not shown.