First of all refer this answer on launching pdf files in Inappbrowser
in Android.
I think you cannot give your local file path in that way.
InAppBrowser
is supported for web content mostly. its in a way similar to Androids WebView
.
Quoting from Inappbrowser - Apache Cordova,
- You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app.
- The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs. For this reason, the InAppBrowser is recommended if you need to load third-party (untrusted) content
Do check this format for opening Local URIs (HTML pages).
You can use ngCordova-FileOpener2 for opening files (including pdf) from the device storage. This uses default application for opening particular type of file.
Working code snippet -
<body >
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<ion-content ng-controller="FileOpenerController">
<button class="button button-full button-positive" ng-click="openPDF()">
Open PDF File
</button>
</ion-content>
</ion-pane>
</body>
Then in JavaScript file use this -
app.controller('FileOpenerController', function($scope, $cordovaFileOpener2, $ionicPlatform) {
$scope.openPDF= function() {
$cordovaFileOpener2.open(
'/sdcard/Download/109.pdf',
'application/pdf'
).then(function() {
console.log('Success');
}, function(err) {
console.log('An error occurred: ' + JSON.stringify(err));
});
};
});
Full tutorial along with the code can be found here.