Using LocalPartRetriever for efficient loading in a Cordova app

43 views
Skip to first unread message

Matt Parizeau

unread,
Sep 2, 2016, 7:14:04 PM9/2/16
to PDFTron WebViewer
Q:

We want to improve the efficiency of loading documents in WebViewer inside our Cordova app and have been trying to use LocalPartRetriever along with the Cordova file plugin (https://github.com/apache/cordova-plugin-file), however we're getting errors when trying to load the document. Is it possible to use LocalPartRetriever inside a Cordova app?

A:

The problem is that WebViewer creates an iframe for the viewer and inside that iframe is where the file is read by the FileReader. The problem can occur when the File object is from the outer window and when LocalPartRetriever tries to use the FileReader from inside the iframe it will be the built in FileReader object and not the FileReader that the Cordova file plugin defines on the outer window.

The solution for this is to add this line to the top of your config file: window.FileReader = window.parent.FileReader so now it is referencing the Cordova plugin's implementation which had been defined on the parent window.
Reply all
Reply to author
Forward
0 new messages