Webviewer Offline Mode

Hi I am working on offline viewing functionality using Webviewer 7, but I got stuck in some issues.

First one to check if document is already in IndexedDB, I use doc.initOfflineDB(); doc.isDownloaded() but it seems to always return false.

Second one is the function setOfflineModeEnabled(true); throws this error:

Uncaught TypeError: Cannot read property ‘ZO’ of undefined
at ua.sp (CoreControls.js:44)
at aa.sp (CoreControls.js:11)
at config_horizon.js?q=78784545814:168
at wn (webviewer-ui.min.js:58)
at webviewer-ui.min.js:239
at hl (webviewer-ui.min.js:34)
at Es (webviewer-ui.min.js:34)
at webviewer-ui.min.js:42
at Go (webviewer-ui.min.js:34)
at Ss (webviewer-ui.min.js:34)

Please suggest me any solution.
Regards.

Hi,

Would it be possible to send some sample code snippets so that I can attempt to reproduce the issue on my end?

Thanks,

Anthony Chen

Software Developer
PDFTron Systems Inc.

Hi,

Thanks for your reply. I am using this code snippet to determine whether the document is downloaded in browser’s IndexedDB, I send the document id to the function, but it seems to always to return false.

function checkDownloaded(id) {
var doc = new CoreControls.Document(id,‘xod’);
doc.initOfflineDB().then(function(){
console.log(doc.isDownloaded());
return (doc.isDownloaded());
});
}

I am passing the correct id of the document. Can you please help me out if I am doing something wrong at my end?

Thanks.

Hello,

The API you are using only works for XOD documents: https://www.pdftron.com/api/web/CoreControls.Document.html#isDownloaded. If you are loading other types of documents, I would recommend looking at the following guide and offline sample for reference:

https://www.pdftron.com/documentation/web/guides/offline-loading/
https://github.com/PDFTron/webviewer-offline-sample

Andy Huang
Software Developer
PDFTron Systems Inc.