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
Console error "Setting up fake worker failed" while using in React #12066
Comments
Please see https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md (emphasis mine):
|
@Snuffleupagus |
Hi, I don't know why, but looks like copy pdf.worker.js to my project's output folder, or use cdn worker will make the magic happen. Using the one from node_modules/ doesn't work.
|
Hi, the same problem happened in my project. I guess it may be related to webpack moudle, but I'm not sure. Do you have any solutions now? (I have to avoid using cdn) |
Hi, does anybody know how to render Uint8Array format within create-react-app? My React component looks like this:
https://stackoverflow.com/questions/63432774/how-to-render-documents-with-pdf-js-and-cra |
Given that we know nothing about React here, is it meaningful to keep this issue open when we unfortunately cannot help? |
Hi,
This works when running it locally, haven't tested this yet when running on a live environment. Kind regards |
With React: import workerSrc from 'pdfjs-dist/build/pdf.worker.entry';
pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc; |
Anybody have a solution for this in angular? |
With Vue : const pdfjsLib = await import('pdfjs-dist') |
Did anyone get solution ? |
@yummyelin |
I am having the same issue right now and I am pulling my hair out as I have been stuck on this for several hours now. I have split my code into two separate files. The fetching from an S3 bucket and then displaying the PDF. But for some reason when I combine the two files where I am both fetching from my S3 bucket and displaying the pdf on the page it works completely fine? Obviously I can't do something like this because of security reasons but its like when I make a separate api file to fetch from my s3 bucket and then pass that to react-pdf in a different file it completely breaks.
|
Attach (recommended) or Link to PDF file here:
https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
Configuration:
Steps to reproduce the problem:
https://github.com/facebook/create-react-app
npm init react-app my-app
npm install pdfjs-dist --save
App.js
(https://github.com/mozilla/pdf.js/blob/master/examples/node/getinfo.jshttps://mozilla.github.io/pdf.js/examples/index.html#interactive-examples for prev/next example)
yarn start
What is the expected behavior? (add screenshot)
Worker is setting up correctly.
What went wrong? (add screenshot)
pdfjsWorker does not exist in window object, which causes 'WorkerMessageHandler' of undefined issue.
The
switch
statement started with case 0 -> case 3 -> case 6 -> case 8, ended up withcatch()
in_setupFakeWorker()
Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
(Trying to push code to my github, but reproducing the issue is very straight forward if following the steps.
all functions are the same as example code.
renderPage()
etc.)The text was updated successfully, but these errors were encountered: