Open local PDF file in Cordova app - Forum

Forum Navigation
You need to log in to create posts and topics.

Open local PDF file in Cordova app

Step1: Install cordova-plugin-file-opener2

Step2: Add your PDF folder in project>properties>files/libraries(example here we added info folder that contains a PDF file by the name of  lemo10.pdf)

step3: Set the below code for a button that you want on click it opens PDF file.

BEGINJS
var uri = "file:///android_asset/www/info/lemo10.pdf";
window.resolveLocalFileSystemURL(uri, function(fileEntry) {
  window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dirEntry){
    fileEntry.copyTo(dirEntry, uri.split('/').pop(), function(newFileEntry) {
       cordova.plugins.fileOpener2.open(newFileEntry.nativeURL,'application/pdf');
     });
  });
});
ENDJS

finally compile your app and it works nice. I was stop on this problem for a week.

luishp and Vadim have reacted to this post.
luishpVadim
Open chat
1
Do you need more info?
Hi, do you have any doubt?