Failed to load PDF file : after version upgrade from 8.0.2 to 9.2.1
Before you start - checklist
- [x] I followed instructions in documentation written for my React-PDF version
- [x] I have checked if this bug is not already reported
- [x] I have checked if an issue is not listed in Known issues
- [x] If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo
Description
Upgraded react-pdf version from 8.0.2 to 9.2.1, issue : Failed to load PDF file
data passing Blob data (type: 'application/pdf')
PDF is displaying with the same code below(version 8.0.2), but after version upgrade(version 9.2.1) getting error.
Steps to reproduce
// entering into onDocumentLoadError and it is priniting "{}" private onDocumentLoadError = (error: Error): void => { if (!this.state.loadError) this.setState({ loadError: true }); this.LogService.LogError('PDFRenderer.onDocumentLoadError', JSON.stringify(error));
console.log(JSON.stringify(error));
};
// Not entering into onLoadSuccess onLoadSuccess = ({ numPages }: any) => { console.log(numPages) this.setState({ pdfPageCount:numPages, });
};
{this.props.ContractFile != null && (
<Document
file={this.props.ContractFile}
onLoadSuccess={this.onLoadSuccess}
onLoadError={this.onDocumentLoadError}
>
{ [...Array(pdfPageCount)].map((_, index) => (
<Page key={index} pageNumber={index + 1} />
))}
</Document>
)}
this.props.ContractFile is a Blob data (type: 'application/pdf')
Expected behavior
Need to display the PDF
Actual behavior
Error : Failed to load PDF file.
Additional information
No response
Environment
- Browser (if applicable): Chrome & Edge
- React-PDF version: 9.2.1
- React version:
- Bundler name and version (if applicable):
Any updates on this?
@rahulmahajannn are you facing same issue ?
I am also facing issue after upgrade from 8.0.2 to 9.2.1
next build
▲ Next.js 15.2.3
- Environments: .env.production, .env
✓ Linting and checking validity of types Creating an optimized production build ... ✓ Compiled successfully Collecting page data .[TypeError: Promise.withResolvers is not a function]
Build error occurred
Windows Version 11 Node - v20.11.0| Next - v15.2.3
@wojtekmaj - Could you suggest if this can be fixed by just upgrading Node to higher versions >=22.0.0 ?
Yep, 22.11.0 and up should be fine according to node.green.
Or, load React-PDF dynamically on the client side only. It's not of much use on the server.
@wojtekmaj , Any Update what is the issue in React. [Failed to load PDF file : after version upgrade from 8.0.2 to 9.2.1]
Yeah, 22 works. Really starting to dislike next.
@wojtekmaj Upgrading to Node 22.14.0 didn't fix it.
I am using react router V7 in framework mode, with vite 6.2.5
The build react-router build doesn't throw any error, but when we try to open the pdf it doesn't work, and shows a msg that failed to load pdf file.
@maxpowernz : Can you please share the steps you followed, that worked the React PDF running in Node 22.
I'm just trying out this library in my react 19 project and I got the same issue, no way to load a PDF. I always get the Failed to load PDF file. No idea why. I'm looking for an alternative.
Same here, been trying for over an hour to add it in my Vite app with the help of cursor, but it seems is very dependent on other libs and it requires weird configs.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.