wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
8.97k stars 861 forks source link

Getting error while displaying a pdf using base64 #1793

Open sourabhchotiads opened 1 month ago

sourabhchotiads commented 1 month ago

Before you start - checklist

Description

I am trying to show a preview of uploaded pdf files and when i integrated this it was working and than i moved the component in an app which is a module fedration app and it stopped working

it always crashes with the error message

Uncaught TypeError: i is not a function at 10045654.js:2:10078 at renderWithHooks (main.js?6559205350d3c6f0efbd:2:210649) at updateForwardRef (main.js?6559205350d3c6f0efbd:2:244599) at beginWork (main.js?6559205350d3c6f0efbd:2:269639) at HTMLUnknownElement._ (main.js?6559205350d3c6f0efbd:2:65358) at Object.invokeGuardedCallbackImpl (main.js?6559205350d3c6f0efbd:2:65695) at invokeGuardedCallback (main.js?6559205350d3c6f0efbd:2:66845) at beginWork$1 (main.js?6559205350d3c6f0efbd:2:328057) at performUnitOfWork (main.js?6559205350d3c6f0efbd:2:312267) at workLoopSync (main.js?6559205350d3c6f0efbd:2:311441)

here is my integration code

<Document
          file={source}
        >
          <Page
            pageNumber={1}
            renderTextLayer={false}
            renderAnnotationLayer={false}
            scale={0.9}
            height={containerHeight}
          />
        </Document>

Steps to reproduce

Pass a base64 string of a pdf to the file prop and it will crash immediately

Expected behavior

It should render the pdf when selected form local machine

Actual behavior

Throwing error

Additional information

No response

Environment

wojtekmaj commented 1 month ago

The code that you've shared looks okay to me. Please provide a reproducible example, e.g. on CodeSandbox, so I could help you out. Otherwise, this issue will be automatically closed after certain time of inactivity.