-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Full PDF doc loaded before single page could be rendered #9537
Comments
The default range chunk size is Line 37 in c33bf80
Only PDF files larger than that will use range (chunked) loading. The server must support range requests and the PDF file must be optimized for web (linearized). If that is the case, then range loading should work just fine for your use case (just try it out with some of your own PDF files to make sure). |
Thanks @timvandermeij! See: http://159.89.108.117/pdfjs-1.10.88/web/load-single.html. I'm using the PDF spec: http://159.89.108.117/PDF32000_2008.pdf. Using HEAD, the first page was rendered when ~4.5MB was downloaded, but it did continue to download the entire file (22.5MB). See: http://159.89.108.117/pdf.js-master/examples/helloworld/load-single.html |
I ran |
@timvandermeij Mind giving some input on this? |
Your example does use range requests (indicated by response codes 206 in the network tab of the console), so that looks fine to me. I think you may want to disable auto-fetching; see: Line 175 in e0fb18a
|
Will this work in case of pdf stored on other domain? Am I missing any parameters here, how can I specify 'range' here? |
Hi @pravid , Did you make it work with pdf being stored on other domains? |
@Hao-Wu , Yes in a way. I used cors proxy to sort this issue. Hope this helps. |
Hi, @pravid i am loading pdf from different source using url /pdfjs/web/viewer.html?file= . It is working fine but loading entire pdf before rendering it. Is it possible to start rendering pdf before complete load? Thank you. |
Yes, check above answer for details. #9537 (comment) Hope this helps. |
Hi @pravid , Sorry, i didn't get much. For example you can look at this link of my website . It loads pdf from gcp bucket and perfectly renders it. But the only issue is, it loads complete pdf before rendering it. For large pdfs it takes some time and the reader is blank for minutes. As far as i think you are telling how to render pdf from source not in domain. But this is not my issue. I have already resolved it by commenting out the line which throws error. As i understood i should use https://myproxyserver.com/https://storage.googleapis.com/... pdf url instead of https://storage.googleapis.com/... which is working fine.. i am not able to understand how this will help and how to implement it. I hope you understood my doubt. Thank you. |
Have you setup your node js server? |
I understood from the FAQ that pdf.js only downloads what it needs, however, using the sample code from the docs, I noticed, via Chrome DevTools' network panel, that the entire document was loaded first, even though a single page was drawn.
Some things I tried to no avail:
qpdf --linearize
on that pdf file.My use case is displaying specific pages from very long PDF files (1000+ pages). If pdf.js is not the right tool please let me know.
Related issues: #1108, #2719, #1923, #1375, #2470, #3461, #6104, #8897.
The text was updated successfully, but these errors were encountered: