This is a solution for storing and opening pdf files inside your app for offline use.
cordova.plugins.fileOpener2.open(
cordova.file.applicationDirectory + 'www/img/sample.pdf',
'application/pdf',
{
error: function (e) {
console.log('Error status:'+e.status+'- Error message:'+ e.message);
},
success: function () {
console.log('file opened successfully');
}
}
);
Opening the pdf should be fairly simple using the cordova.plugins.fileOpener2 plugin, but I ran into a strange issue because my app name in the config.xml contained a space such as: <name>My App</name>. This caused the iOS to misread the file path. Removing this space in the app name fixed the file path on iOS.
I put the sample pdf doc in the ionic project under my images folder www/img/sample.pdf.
Good luck!
