Support gzip in range request / Explicitly set accept-encoding: identity
See original GitHub issueI’m using react-pdf
, which in turn uses pdf.js
(awesome library, guys!), for a web application that shows open governmental meeting documents (demo).
I noticed that for large PDF files, loading takes a while, and it seems like pdf.js
downloads the entire file before rendering the first page.
The docs mention that PDF.js fetches only the necessary data, if the server supports Content-Range header / Range requests.
The server (Google Cloud Storage) seems to support ranges (example file).
GET https://storage.googleapis.com/ori-static/api.notubiz.nl/document/6131301 HTTP/1.1
Range: bytes=0-1999
The maintainer of react-pdf
told me it should work If we simply pass a URL to pdfjs.getDocument
, but it does not.
Is it true that getDocument should use the Range header if only a URL is passed?
Am I missing something? Should I manually create a PDFDataRangeTransport
? Thanks in advance for your time!
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (2 by maintainers)
Top GitHub Comments
Let’s reopen this. @yurydelendik @brendandahl Do you have any comments on https://github.com/mozilla/pdf.js/issues/11027#issuecomment-518180185?
According to the specifications, see e.g. the XMLHttpRequest specification which links to the relevant part of the Fetch specification, the
Accept-Encoding
cannot be set (other than the by browser itself); see also https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name Hence it won’t be possible to addAccept-Encoding: identity
to the network requests made by the PDF.js library.With regards to adding support for
gzip
in the various stream implementations, that would risk adding a lot of additional complexity to the relevant code (not to mention the time/effort required to implement/review/test something like that). Furthermore, the problem in this issue seem to be limited to a particular server rather than be a widespread issue.All-in-all, it seems that WONTFIX probably is the appropriate resolution for this issue.