Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE11 not able to load PDFJS worker #560

Closed
4 tasks done
FrederickEngelhardt opened this issue Apr 30, 2020 · 8 comments
Closed
4 tasks done

IE11 not able to load PDFJS worker #560

FrederickEngelhardt opened this issue Apr 30, 2020 · 8 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@FrederickEngelhardt
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in Mozilla Firefox

Description

IE11 does not render PDFs with 5.0.0-beta.3 or latest version 4.1

Steps to reproduce

Steps to reproduce the behavior:

  1. Use IE11
  2. Load any PDF using a URL (or local file)
  3. See the following error
    Screen Shot 2020-04-30 at 7 56 38 AM

Also noting that with this library I have to add a worker SRC otherwise the PDF will not load.

import { Document, Page, pdfjs } from 'react-pdf'
...
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`

Expected behavior

IE11 should load PDF js documents. Also noting that @mikecousins/react-pdf will load. So perhaps there is a method or configuration to support IE11 that is missing.

Additional information

Environment

  • Browser (if applicable) [e.g. Chrome 57, Firefox 59]: IE11 (chrome & firefox have no issue)
  • React-PDF version [e.g. 3.0.4]: 4.1 and also tested on 5.0.0-beta.3
  • React version [e.g. 16.3.0]: 16.13.0
  • Webpack version (if applicable) [e.g. 4.16.2]: 4.42.0
@FrederickEngelhardt
Copy link
Author

FrederickEngelhardt commented Apr 30, 2020

Side note, 5.0.0-beta.2 works. But not seeing any text elements rendering.

@wojtekmaj
Copy link
Owner

If you use beta.3 with forced version of pdf.js that was used in beta.2 (yarn set resolution pdfjs-dist@2.3.200 2.2.228), does it work?

@wojtekmaj wojtekmaj self-assigned this Apr 30, 2020
@FrederickEngelhardt
Copy link
Author

FrederickEngelhardt commented May 4, 2020

Not using yarn. But going into the package.lock and making the change in pdf-js should be the same. Got the same worker error.

Tried this as well.

pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.worker.js`

package.lock.json

    "react-pdf": {
      "version": "5.0.0-beta.3",
      "resolved": "https://registry.npmjs.org/react-pdf/-/react-pdf-5.0.0-beta.3.tgz",
      "integrity": "sha512-+5JXiER6DDOiyCLvYjjLPyqTb1eKANFOS0v6IjxYXctC2uMG/jvD5wcTlqLlB2WAwgRtdcZYWZ2lyWDteRGvmw==",
      "requires": {
        "@babel/runtime": "^7.0.0",
        "make-cancellable-promise": "^1.0.0",
        "make-event-props": "^1.1.0",
        "merge-class-names": "^1.1.1",
        "prop-types": "^15.6.2"
      },
      "dependencies": {
        "pdfjs-dist": {
          "version": "2.2.228",
          "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.2.228.tgz",
          "integrity": "sha512-W5LhYPMS2UKX0ELIa4u+CFCMoox5qQNQElt0bAK2mwz1V8jZL0rvLao+0tBujce84PK6PvWG36Nwr7agCCWFGQ==",
          "requires": {
            "node-ensure": "^0.0.0",
            "worker-loader": "^2.0.0"
          }
        }
      }
    },

@FrederickEngelhardt
Copy link
Author

FrederickEngelhardt commented May 5, 2020

Also noting that the demo url http://projects.wojtekmaj.pl/react-pdf/ does not load for ie11.

Error says Promise is undefined. So the demo url probably needs a polyfill.
Screen Shot 2020-05-05 at 9 59 11 AM

@stlst
Copy link

stlst commented Jul 5, 2020

Faced the same error. Does react-pdf support ie11?

@wojtekmaj
Copy link
Owner

It does, but IE11 doesn't support Promises. So you either need to add all necessary polyfills until it stops crashing, or configure Babel properly to do it for you.

@david-pulse
Copy link

Facing issues with IE11 as well... I do think it needs to be a babel configuration problem... It appears that my webpack configuration is not compiling the react-pdf import of pdfjs-dist to es5.

When I look at the compiled code, it is still using es6 code which is why it's failing on IE11. It would be great if we could get an IE11 compatible config.

@wojtekmaj
Copy link
Owner

Unfortunately, in v5, support for IE 11 has been dropped. There's nothing we can do about it. Sorry about that!

If you still need to continue support IE 11, you're stuck at v4.x.

See thread: #495 (comment)

@wojtekmaj wojtekmaj added the wontfix This will not be worked on label Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants