Mobile: Not able to display XOD document from Android application data directory

90 views
Skip to first unread message

Vinoth Kumar

unread,
May 11, 2016, 12:33:39 PM5/11/16
to PDFTron WebViewer
Hi,

We have a hybrid app and we are using WebViewer to load the XOD document in Mobile.

The process is like:
1. Get the XOD file from server
2. Save the file in Application Data Directory (e.g. file:///data/user/0/<bundle_id>/files/form.xod). 
3. Refer the path in initialDoc for displaying in Mobile

But for some reason, I am getting an error as 'XOD load error'. Please check the attachment for error details.

XOD doesn't have any issue because I am able to use the same XOD locally and it worked. I also tried saving the file in Application data directory and Application cache directory but no luck.

Sample Code:
                                var fileTransfer = new window.FileTransfer();
var uri = encodeURI(<server_url>);

var path = window.cordova.file.applicationStorageDirectory + 'form.xod' ;

fileTransfer.download(
uri,
path,
function(entry) {
var myWebViewer = new window.PDFTron.WebViewer({
path: 'vendor/webviewer/lib',
type: 'html5,html5Mobile',
mobileRedirect: false,
initialDoc: entry.toURL(),
documentType: 'xod',
documentId: 'form',
config: '../www/vendor/webviewer/lib/templateConfig.js',
enableAnnotations: false,
streaming: true,
showToolbarControl: false
}, viewerElement);
}
);


Please advice me.

XOD_Load_Error.png

Anatoly Kudrevatukh

unread,
May 11, 2016, 4:30:54 PM5/11/16
to PDFTron WebViewer
Hello,

This error means that WebViewer is unable to fetch the file from location specified in initialDoc.

Typically browsers are not allowed to fetch files from the filesystem. Meaning passing this as an initialDoc file:///data/user/0/<bundle_id>/files/form.xod will not work in a regular browser due to security restrictions

However that might be different or configurable in cordova framework. I have prepared a custom build that should ignore return status 0 when a file protocol is used. Please let me know if this build works for you

Vinoth Kumar

unread,
May 13, 2016, 12:44:09 PM5/13/16
to PDFTron WebViewer
Hello,

The build is working without any issues, thanks for the support.

Regards,
Vinoth

Michael Lee

unread,
Jun 9, 2016, 2:09:09 PM6/9/16
to PDFTron WebViewer
I also confirm this works with Cordova FileTransfer plugin on both Android and iOS.

Mike
Reply all
Reply to author
Forward
0 new messages