Before you start - checklist
What are you trying to achieve? Please describe.
I've upgraded from Version 3.0.5 to 4.0.5. After the update my PDF-Files will not be displayed anymore and it keeps "loading".
Describe solutions you've tried
I display my PDF-File as base64-data but tried plain bytes too. Using the provided notification hooks gives me the feedback, that sourcedata is loaded correctly.
Debugging into your code leads me to Document.js and this code:
cancellable = (0, _utils.makeCancellable)(loadingTask.promise);
_this.runningTask = cancellable;
_context.next = 23; // until here is everything fine
return cancellable.promise; // this promise is never resolved
Additional information
I use your lib straight forward:
import { Document, Page } from "react-pdf/dist/entry.webpack";
<Document
file={ isDataBase64 ? `data:application/pdf;base64,${file}` : file }
loading="Das PDF wird geladen..."
onLoadSuccess={ ::this.onDocumentLoadSuccess } // show additional buttons for zoom
className="pdfDocument"
renderMode="svg"
>
<Page
key={ `page_${1}` }
pageNumber={ 1 }
className="pdfPage"
renderMode="svg"
scale={ pageScale } />
</Document>
I've attached a sample PDF for you. Copy+paste it into your browser will work. Using it at the parameter for <Document file={<pdfdata here>}>
does not work.
samplePDF_base64.txt
Environment
It definitely worked for me both pasting it in browser's address field and passing as an URL to file
prop in React-PDF! Maybe you're "base64-ing" it twice?
No, this pdf-data is equal to the string, I pass into Document.
Is there any way to find out what PDFjs is doing?
Damn, this caching.
Deleting all the site caches in Chrome made it work.
Thanks for your fast answer!
In case it's helpful to anyone else, I also experienced the same never-resolving promise behaviour when I'd accidentally set the url for the worker (pdfjsLib.GlobalWorkerOptions.workerSrc = "....") to point to the main pdf.js file instead of the pdf.worker.js file by mistake.
Most helpful comment
In case it's helpful to anyone else, I also experienced the same never-resolving promise behaviour when I'd accidentally set the url for the worker (pdfjsLib.GlobalWorkerOptions.workerSrc = "....") to point to the main pdf.js file instead of the pdf.worker.js file by mistake.