InvalidPDFException {name: "InvalidPDFException", message: "Invalid PDF structure"
See original GitHub issueI am using 4.0.0-beta.5 but still I am getting InvalidPDFException for this file
InvalidPDFException {name: "InvalidPDFException", message: "Invalid PDF structure"
My Component:
import React from "react"
import { Document, pdfjs } from "react-pdf"
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${ pdfjs.version }/pdf.worker.js`
class Sample extends React.Component {
render(){
return(
<div>
<Document file="/Users/laptop/Desktop/sample.pdf" />
</div>
)
}
}
Also, there are lot of warning on console
_Originally posted by @Puspendert in https://github.com/wojtekmaj/react-pdf/issues/291#issuecomment-438381865_
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
javascript - react-pdf-js - Uncaught (in promise) e {name ...
react-pdf-js - Uncaught (in promise) e {name: "InvalidPDFException", message: "Invalid PDF structure"} · Subscribe to RSS.
Read more >Hi, I am trying to upload a pdf file but this message appears ...
3D FlipBook - Hi, I am trying to upload a pdf file but this message ... emessage: “Invalid PDF structure”name: “InvalidPDFException”proto: Error at...
Read more >PDF Invalid Structure - Power Platform Community - Microsoft
Solved: Hello everyone, With help of Abm user on this link, I cretaed a Flow that takes all PDF in a librairy and...
Read more >Error = Invalid PDF structure, while viewing and downloading ...
I noticed a friend had an older version of Brave where a list of extensions were natively proposed. Here is what I have...
Read more >TB and Gmail: performance problem? - Topicbox
... resource://pdf.js/web/viewer.js:1184 14:48:09.212 Uncaught (in promise) Object { message: "Invalid PDF structure.", name: "InvalidPDFException", stack: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Guys, react-pdf accepts only http protocols. So, if you are testing any pdf on your machine, the browser URL will likely be “file: //home/myComputer/localOfFiles/myPdf.pdf” and the correct path should be “http://localhost:3000/myPdf.pdf”.
You don’t need to use any extension or anything else, you just move a file.pdf to your public folder in React code and try this path “http://localhost:3000/myPdf.pdf” to see if your browser will render something.
Here is some sample code:
Try this
import file from './x.pdf';