- Notifications
You must be signed in to change notification settings - Fork0
Open
Description
I have PDFs as large as 1GB on my platform but I have ensured they are "linearized". With your viewer:
- The viewer seems to be trying to load the whole file before attempting rendering
- Pdf.js does support range requests but may need some configuring on your end
- If I try to load a PDF by assigning the :url but then “cancel” by unmounting the PDF viewer, the download continues in the background
- That could mean the client sucking up the bandwidth without even realizing!
To address the first point, I recommend exposing props like
- disableAutoFetch
- disableStream
- rangeChunkSize
which can get passed to pdfjs.getDocument and I can override these to not load the whole document unless needed.
You may still need to be careful on loading page by page both in canvas and the thumbnail strip - I don't know if your viewer always renders all pages in advance.
To address the second point, pdfjs.getDocument returns a loading that can be cancelled on events unlike unmount
I've successfully tested this approach with this codehttps://github.com/Brief-Tech-Pte/localdoctools/tree/main/src/components/pdf-viewer albeit this is using pdf.js v5 and I think you guys are on v4.
This capability can be tested by loading a synthetic 100 page 50MB PDF and observing the viewer on loads what is required to view the pages being rendered. The linked repo above has this test case.
Metadata
Metadata
Assignees
Labels
No labels