"Invalid or corrupted PDF files" is displayed
See original GitHub issueAttach (recommended) or Link to PDF file here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.144.7135&rep=rep1&type=pdf
Configuration:
- Web browser and its version: Chrome 72.0.3621.121 (Official Build) (64-bit)
- Operating system and its version: MacOS
- PDF.js version: PDF.js v2.0.673 (build: 31012570)
- Is a browser extension: Yes
Steps to reproduce the problem:
- Click the above link
What is the expected behavior? (add screenshot)
This is what I can see when I pasted chrome-extension prefixed url or reloading the error pdf page.
(chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.144.7135&rep=rep1&type=pdf
)
What went wrong? (add screenshot) This is what I can see when click the above link
Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension): https://chrome.google.com/webstore/detail/pdf-viewer/oemmndcbldboiebfnladdacbdfmadadm
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
PDF Links will not open, result in "invalid or corrupted" warning
Several sites with PDF links result in “Invalid or corrupted PDF file” message instead of displaying or downloading the file.
Read more >Error: Invalid or corrupted PDF file Firefox - Stack Overflow
It looks like you've overengineered the solution a little bit document.getElementById('uploadedFileIframe').src = reader.result;.
Read more >Ways to fix “Format Error: not a PDF or corrupted”
Your answer to restore entire corrupt PDF file is PDF file repair software; the final way to fix this error is by repairing...
Read more >Repair Corrupted or Damaged PDF File with 4 Ways
Part 1: Possible Reasons for PDF File Corrupted or Damaged? · Improper download: While downloading the PDF files, sometimes you have an unstable...
Read more >'Invalid or corrupted PDF file' error when loading a Word ...
If the converted pdf file is not present in sys_attachment table, then it will convert again, so showing correct the next time the...
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 FreeTop 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
Top GitHub Comments
I found the cause of this issue. The reason is requesting twice to server in a very short interval. To the second request, server redirects to
downloadsexceeded.html
instead of pdf content. So, pdf.js complains it’s invalid/corrupted pdf file. It’s maybe server’s DDoS protection I think.Why two requests are issued when user clicks that link? First one is issued by browser for user click. Then, pdfjs extension intercepts header response and redirects to extension url. Then, one more requesting is issued by
pdf.js
.I think we can improve this more. How about using the contents received from first request instead of requesting again? This is just an idea. (Sorry, if this idea doesn’t make sense. I don’t fully understand about pdf.js/extension implementation now.).
WDYT? @timvandermeij @Rob--W
Closing since this seems to work again.