You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preview itself fails with "Failed to load PDF file." message.
What is odd, is that it works fine with the regular path, ie. It only fails when I switch the path to legacy build
pdfjs.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url, ).toString();
I believe this behaviour is only when run in Storybook, because when we use this version of our custom library for PDF preview in another React application it seems to work without this error.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We need to support older browser through adding polyfill for Promise.withResolvers function and hence we import legacy build of pdfjs-dist.
However when we change the path to legacy build, i.e.
it fails with -
pdf.mjs:1172
GET http://localhost:6006/[object%20Module] net::ERR_ABORTED 404 (Not Found)
Warning: Error: Setting up fake worker failed: "Failed to fetch dynamically imported module: http://localhost:6006/[object%20Module]"
Preview itself fails with "Failed to load PDF file." message.
What is odd, is that it works fine with the regular path, ie. It only fails when I switch the path to legacy build
pdfjs.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url, ).toString();
I believe this behaviour is only when run in Storybook, because when we use this version of our custom library for PDF preview in another React application it seems to work without this error.
"react-pdf": "^9.0.0",
"pdfjs-dist": "4.3.136",
Chrome - 116
Beta Was this translation helpful? Give feedback.
All reactions