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.34k stars 882 forks source link

Improvement: Preload Pages and Cache loaded pages #1816

Open nikischin opened 4 months ago

nikischin commented 4 months ago

Before you start - checklist

Description

I just integrated this library in my App and it’s a huge upgrade compared to an iframe from a visual perspective. However, talking about performance it cannot compete with an iframe. And that is totally ok, though I was wondering if it would be possible in a future version to automatically preload the next page and keep the previous few pages in memory maybe? Because changing pages really takes some time and even when you go back to pages previously rendered they need to load again (without even showing the loading indicator and just being white).

Proposed solution

Automatically preload the next (or even next few) pages. Keep previous few pages in Memory. Also preload the previous page if not in memory already.

Thank you!!

github-actions[bot] commented 1 month 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.

nikischin commented 1 month ago

@wojtekmaj how can a Feature Request get stale? :)

wojtekmaj commented 1 month ago

I guess you could make a proxy component like OffscreenPage by rendering Page component, with text and annotation layers turned off, and customRenderer noop function? 🤔 You also have useDocumentContext hook which enables you to programatically get pages as you need.