File opener - opening local pdf file in file system getting file not found


#1

Im trying to open a local pdf file

in my ionic project im saving the file in the www/pdf directory

when i m trying to open the file using ng-cordova for this plugin im getting file not found…
here is the latest version of the code

    $cordovaFileOpener2.open(
    "file:///android_asset/www/pdf/test.pdf",
    'application/pdf'
  ).then(function(event) {
      // file opened successfully
      console.log(event);
  }, function(err) {
      // An error occurred. Show a message to the user
      console.log(err);
  });

#2

i think you are working with a wrong path. you can take a look where the root of your localfilesystem if you are wrinting the file.


#3

ummm…
Can you please elaborate?
when ionic builds the APK then the www/pdf folder is moved to another location

if i open the APK i see the following structure

assets/www/pdf

however if i write this path in the code i keep getting file not found…


#4

First FileOpener2 has such a bad documentation. I don’t know why is it even included into ngCordova collection.

You CAN’T use it to open an assets content so forget about it. Files must be placed inside a real system directory.
It will not work if you don’t have a dedicated application for that file type. So make sure to check it before doing anything.

Read more about it here.