Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF file not loading when upgrading the version from 5.0.0 to 7.7.3 #1946

Open
4 tasks done
v-sreeraghuv opened this issue Feb 18, 2025 · 2 comments
Open
4 tasks done
Labels
question Further information is requested

Comments

@v-sreeraghuv
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

Currently we are using react-pdf with 5.0.0 and we are getting the data with Uint8Array Binary Data. But after upgrading the version to 7.7.3 the PDF loading stopped and we are facing error as PDF Not found. Below is the code which we are using previously. Please help to resolve this ASAP or is it a known issue.

public render(): JSX.Element {
    // const { ContractFileExtension } = this.props;
    const { pdfLoaded } = this.state;
    return (
        <div style={{ height: document.body.offsetHeight }}>
            {this.props.ContractFile != null && (
                <Document
                    file={{ data: this.props.ContractFile }}
                    onLoadSuccess={(pdf: IReactPdf): void => {
                        if (!pdfLoaded) {
                            this.setState({ pdfPageCount: pdf.numPages, pdfLoaded: true });
                        }
                    }}
                    onLoadError={this.onDocumentLoadError}
                >
                    {this.generatePages()}
                </Document>
            )}
            {this.props.ContractFile == null && !this.state.loadError && !this.props.findDocumentError && (
                <LargeCustomShimmer />
            )}
            {(this.state.loadError || this.props.findDocumentError) && (
                <Icon style={{ fontSize: '160px' }} iconName="DocumentSearch" />
            )}
            {/*ContractFileExtension !== 'pdf' && (
                <>
                    <h5>Only PDF preview is available at this time.</h5>
                    <Icon style={{ fontSize: '160px' }} iconName="WordDocument" />
                </>
            )*/}
            {this.props.findDocumentError && <p>You do not have permission to view the document.</p>}
        </div>
    );
}

}

Steps to reproduce

Update the version from 5.0.0 to 7.7.3 where we can see this issue

Expected behavior

Need to load the PDF with version 7.7.3

Actual behavior

Throwing error as No PDF Found

Additional information

No response

Environment

  • Browser (if applicable):
  • React-PDF version:
  • React version:
  • Bundler name and version (if applicable):
@v-sreeraghuv v-sreeraghuv added the bug Something isn't working label Feb 18, 2025
@wojtekmaj
Copy link
Owner

"PDF Not found" is not coming from react-pdf, there is no such error. I suppose you're hiding the real error message behind one of your own.

Also:

file={{ data: this.props.ContractFile }}

this bit is not correct, because you're creating a new file object on each render. See https://github.com/wojtekmaj/react-pdf#props

@wojtekmaj wojtekmaj added question Further information is requested and removed bug Something isn't working labels Feb 20, 2025
@1Jesper1
Copy link

@v-sreeraghuv Maybe try upgrading to v6 or v7.0 first. Do you get an error in the console?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants