Closed schvenk closed 1 year ago
Same Issue
I had the same issue, then after reading the rest of the README i came across this section then after adding this to my code it worked.
import { Document, Page, pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.js`;
Duplicate of #994 Duplicate of #991 Duplicate of #680 Duplicate of #52
I have the same Issue.(Uncaught SyntaxError: Unexpected token '<' (at vendors-node_modules_pnpm_react-pdf_7_3_0_zula6vjvt3wdocc4mwcxqa6nzi_node_modules_react-pdf_d-e61ade.chunk.worker.js:1:)
now is resolve
import { Document, Page, pdfjs } from "react-pdf";
pdfjs.GlobalWorkerOptions.workerSrc = //cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js
;
Before you start - checklist
Description
I have been unable to get
react-pdf
working, even in a very simple sample app. (The sample app in the repo also doesn't work for me, though that's a different error.) Here's what I've tried.npx create-react-app pdftest
sample.pdf
file insidepdftest/public
. I've tried two of my own PDFs as well as the sample PDF from the repo.App.js
, remove all boilerplate code inside the outermost<div>
and replace with<Document file="./sample.pdf" />
yarn start
Any idea what's going on?
Steps to reproduce
See above.
Expected behavior
PDF renders.
Actual behavior
Error as described above.
Additional information
No response
Environment