1

I need to open a pdf in a hybrid app, the pdf is previously downloaded by the hybrid app (the app has both read and write from external storage). I can retrieve via fileSystem the file entry:

someDirEntry.getFile(fileName, {create: true, exclusive: false}, openViewPdf, ioFail);

in openViewPdf I can read the path of the file:

function openViewPdf(fe){

console.log("V1 "+fe.toURL());
console.log("V2 "+fe.fullPath);
//console.error("V3 "+toNativeURL()); //not supported by 2.3.0

window.open(fe.toURL(), '_system');

}

the output is something like:

V1 file:///mnt/sdcard/someDir/fileName.pdf
V2 file:///mnt/sdcard/someDir/fileName.pdf

i.e. there is no difference between fullpath and .toURL(). A new window opens, but in the new window I see an error alert:

There was a network error. (file:///android_asset/www/fileName.pdf

It's like the InAppBrowser tries to open the pdf in the asset directory of the app (which of course is wrong!) the proper path is the ones listed above. Isn't there any way of making this work other than trying the extra plugin (see: Phonegap how to download and open pdf file in android app)?

Community
  • 1
  • 1
T. Rossi
  • 465
  • 1
  • 6
  • 23

1 Answers1

0

After plenty of work the answer is: "No, there is no way of opening a pdf with InAppBrowser in Android". The upside is that the plugin is easy to do in java.

T. Rossi
  • 465
  • 1
  • 6
  • 23