Hi, please can you tell me how the HTTP stream is supposed to work? I was hoping it would open a remote PDF and allow the user to scroll through while the PDF was being downloaded from the remote location - however it appears to just download the entire file in a synchronous manner before displaying the first page?
Is there going to be an update which allows HTTP streaming to work while the user is viewing the PDF - i.e. load the pages on demand from the remote location as the user scrolls to them?
I've looked into this a little more and the way this works is a little odd. There is a temporary file created that matches the size of the full PDF, then the PDF library seems to download the entire file from the remote location in a synchronous fashion (blocking the UI thread).
The first page or two of the PDF are shown in the PDF viewer - at this point if you open the temporary file it has created in Preview (on Mac) then you see the first couple of pages have been downloaded and written to the file but the remainder of the PDF is empty - there are placeholders for images etc it would seem.
If you then scroll the PDF viewer one or two pages and then re-open the temporary file ALL the PDF is now present. It would seem as if the entire PDF was in memory but has been suddenly flushed to the temporary file.
The actual behaviour we want when using the new PDFHTTPStream class is for it to open the remote file immediately and display the first pages, scrolling the PDF causes further requests to be made to the server (with Range headers) in order to get more pages of the document. These should be cached to the temporary file as needed.
Can you tell me how to achieve this with the library?
Hi, I agree that the HEAD request was taking a long time, in our case we know the file size before hand, so I modified the PDFHttpStream "open" method to accept the file length. If this was passed, it was used in place of making the HEAD request call. This removed that issue.
However this is not the main issue - the issue is that the call to Document_openStream in PDFObjc.m causes ALL the remote PDF file to be downloaded.
The source for "Document_openStream" is not available so I cannot see what is happening in there, but I suspect your code must be causing the entire file to be fetched, possibly to obtain the total page count.