window.open(\"http://google.com\") - works fine
window.open(\"data:application/pdf;base64,{base64EncodedString}\") - opens fine on iOS devi
Please use plugin file opener for that .Here is the plugin .
run this command in your working directory .
cordova plugin add cordova-plugin-file-opener2
basic usage
PDF File opener code
cordova.plugins.fileOpener2.open(
'/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf
'application/pdf',
{
error : function(e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success : function () {
console.log('file opened successfully');
}
}
);
Please also check this url it is the plugin git directory and also have some example to open files. A File Opener Plugin for Cordova
I would also suggest using In App Browser plugin.
You can install it by running:
cordova plugin add org.apache.cordova.inappbrowser
in your CLI (in case if you are using Cordova 3.x). Earlier versions such (2.8.0, 2.9.0 etc) should have it pre-installed.
Ton open PDF documents in a new window use:
window.open('http://your-url.com/yourPDF.pdf', '_blank'); You might be able to use '_system option instead of '_blank' but i'm not sure about the outcome, it might open a system defined PDF viewer
Looks like I have to use
window.location.href = "data:application/pdf;base64,{base64EncodedString}"
instead of window.open("data:application/pdf;base64,{base64EncodedString}");