stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
481 stars 182 forks source link

Support for range requests #14

Closed m-te closed 5 years ago

m-te commented 5 years ago

When you open this file for ex(http://www.peoplelikeus.org/piccies/codpaste/codpaste-teachingpack.pdf) in chrome or firefox, the file begins displaying first pages as it's downloading, but viewing it in ngx-extended-pdf-viewer it downloads the whole file before showing the first page, I was wondering if behaviour similar to viewing it through browser address bar might be possible, to show pages as they download.

This is same for ng2-pdf-viewer and ng2-pdfjs-viewer, I haven't tested with default pdf.js library yet, there is also this:https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#range.

Also to mention that when you view the file using embed or object tag, you get same behaviour - views pages as they are downloading. I am not sure if this is a limiting of using external packages other that browser default or related to module, it's most likely the former, but having lazy-loading kind of behaviour is one of my main motivations for using this library

stephanrauh commented 5 years ago

Actually, ngx-extended-pdf-viewer already does that. It took me a while to figure out how to show this. Open your browser's developer tools and limit the network speed to something like "fast 3G". Now open the PDF file in the ngx-extended-pdf viewer (and see to it you load it from an URL). In my case, I simply started my demo with ng s -o to open the BootsFaces presentation (53 pages, 1.5 MB).

After some 30 second the Angular code has been loaded, the PDF viewer frame is rendered. The first view of the document is shown after 50 seconds. The document finishes loading after 1.7 minutes. The PDF file itself is loaded in chunks of 64 KB.

captura de pantalla 2018-11-27 a las 22 18 14

(Image taken with 5Mit/s)

image (Image taken with "fast 3G")

stephanrauh commented 5 years ago

I've closed the ticket. Nonetheless, I'd like to hear from you. Did my answer help you? If not, which browser and which OS are you using?

m-te commented 5 years ago

Thanks for the reply, I am using chrome 70 with Mac OS X 10.13.6, in my case opening the file link I mentioned above in this demo: https://github.com/stephanrauh/ExploringAngular/tree/master/embedding-pdf gives following result, screen shot 2018-11-28 at 10 35 43 (https://drive.google.com/open?id=1SerzyUjXFaKsPhdg6wpSVrnOU9F6Bmcs) screen shot 2018-11-28 at 10 38 25

(https://drive.google.com/open?id=1Z7QQTW73s6A6OFzfnt1ak0KccaYKpy8C) reading from mozilla's faq it might be because the pdf is not linearised/optimised for web, however using a different link that doesn't work as intended in browser address bar either(http://ftp.geogratis.gc.ca/pub/nrcan_rncan/publications/ess_sst/222/222861/mr_93_e.pdf) gives similar result screen shot 2018-11-28 at 10 47 56

(https://drive.google.com/open?id=1dbFZJqTssz0e2pTnnKT7UQfR04doDYlk) I am not sure if it's the pdfs I am using then, can you give link to the file you've used in screenshots above?

stephanrauh commented 5 years ago

Sure. I've added it to the repository: https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/master/src/assets/pdfs/BootsFaces_Deep_Dive_1.0.pdf

stephanrauh commented 5 years ago

@m-te Another question: do you know the license your demo PDF has been published under? I'd like to add it to the showcase, but of course, I need to double-check for the license first.

m-te commented 5 years ago

I don't know about the licence since I just picked it up from web(https://bit.ly/2AzQID6), so can't say, but as for the demo I had used the minimal one on npmjs, instead of this(https://github.com/stephanrauh/ngx-extended-pdf-viewer), but even so I can't get it to work as needed now, I tried the same link and uploaded the BootsFaces pdf to drive, but they both show same old behaviour for me, however loading from disk does result into several 206 requests which what I think is range request code.

stephanrauh commented 5 years ago

Maybe the server need to support loading chunks of the file. At the moment, I don't know how to investigate the topic further, but I'll keep it in mind. Hopefully one of us finds out one day or another!