wojtekmaj / react-pdf

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

Rendering a large pdf behind a fabric JS canvas and drawing over the canvas is crashing on mobile , tablets and ipad devices. #868

Closed suseendran1993 closed 2 years ago

suseendran1993 commented 3 years ago

Scenario:

We have a feature where we need to load pdf behind the fabric js canvas and need to perform some action over it, this works fine for smaller pdf let's say less than 2 MB but with larger Pdfs the application is getting crashed on mobile or ipad devices when we perform any action.

I even tried loading pdfs page by page but it still causes the applicaton to crash.

Expected behaviour:

Pdfs of larger sizes should work without crashing when we perform any action on canvas over it.

Environment

amcipher commented 3 years ago

You can use React Virtuso to render a list of Pages, it will resolve slow rendering issues. Tested on iPad too. https://www.npmjs.com/package/react-virtuoso

<Document
      className={classes.document}
      file={{url:fileUrl}}
      onLoadSuccess={onDocumentLoadSuccess}
      onLoadError = {(error) => alert('Error while loading document! ')}
  >
    <Virtuoso
      style={{ height: 500 }}
      totalCount={numberOfPages}
      itemContent={index => <Page 
          key={`page_${index + 1}`} 
          pageNumber={index + 1}
     />}
  />
</Document>
github-actions[bot] commented 2 years ago

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.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 14 days with no activity.