Quote from
asmat on March 6, 2021, 4:40 am
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.
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.