Failed to save files for offline use for a few documents

63 views
Skip to first unread message

Samer Albahra

unread,
Aug 9, 2016, 5:27:51 PM8/9/16
to PDFTron WebViewer
Hello,

We are developing an application which uses an embedded PDFTron WebViewer. The problem we have is for a few documents when saving a file for offline, it reports success but didn't write anything to the IndexedDB. This is happening in both Chrome and Firefox browsers. I can say it's only three of many documents tested but nonetheless it is occurring. This is the code I am using to save the file for offline (when the viewer isn't open).

var partRetriever = new CoreControls.PartRetrievers.StreamingPartRetriever( location, CoreControls.PartRetrievers.CacheHinting.CACHE ),
doc = new CoreControls.Document( ItemID );

doc.loadAsync( partRetriever, function( err ) {
if ( err ) {
unloadCoreControlDocument( doc );
return;
}

doc.initOfflineDB( function() {
doc.storeOffline( function() {
unloadCoreControlDocument( doc );
}, tick );
} );
} );

The ItemID is an internal pointer to our db ID and the location is the complete URL to the XOD document. The return shown in the browser is a 200 but in the instances where it fails, the browser says: Failed to load response data.

Do you have any idea what may be causing this? If you need additional information please let me know.

Thank you,
Samer

Samer Albahra

unread,
Aug 10, 2016, 12:53:38 PM8/10/16
to PDFTron WebViewer
Also, as a seperate question, you may notice the `tick` function after the complete function for storeOffline. This never works and sends all the data at once (at the very end). Is there any reason for that?

Thank you again!

Matt Parizeau

unread,
Aug 10, 2016, 7:21:59 PM8/10/16
to PDFTron WebViewer
Hi,

We haven't seen this issue before. Would you be able to send one of the documents that you're having the problem with?

For your second question could you try using the HttpPartRetriever instead of the StreamingPartRetriever and see if that improves things for you. There are some differences in how they fetch and process data which affects the reporting for storing offline.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Samer Albahra

unread,
Aug 11, 2016, 5:11:48 PM8/11/16
to PDFTron WebViewer
Thank you Matt for the quick reply. I am working on getting a copy of the XOD in question for you but to follow up on the second question, using HttpPartRetriever throws the following error: "Invalid XOD file: Zip end header data is wrong size!".

The StreamingPartRetriever works however maybe the issue of it failing on some documents is linked to HttpPartRetriever not working as shown above? Any ideas?

Thank you,
Samer

Matt Parizeau

unread,
Aug 12, 2016, 6:12:52 PM8/12/16
to PDFTron WebViewer
Hi Samer,

That could be related, it could be that your server doesn't support the HTTP range header on requests so it's downloading the entire file instead of just the specific bytes that HttpPartRetriever is requesting (which is why it says the data is the wrong size).

This tutorial has some more information about streaming and range requests http://pdftron.com/webviewer/demo/tutorials/streaming-option.html.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages