How to open external pdf url in app

can any one tell me how to open external pdf in ionic app…

1 Like

The way i have done this is using phonegap InAppBrowser plugin. simple and sweet :slight_smile:

1 Like

can you give me the example so i will try…

  1. Install this plugin

  2. Function to open link inside inAppBrowser. This can be any link like html, image or pdf. In case of android we use GoogleDocs to open pdf file as by default android browser does not support pdf viewing. iOS is smart enough to handle pdf itself as usual :slight_smile: .

Example :

 $scope.view_link = function (url, link_type) {
            if (ionic.Platform.isAndroid()) {
                if (link_type !== undefined && link_type !== null) {
                    if (link_type.toLowerCase() !== 'html') {
                        url = '' + encodeURIComponent(url);
            var ref =, '_blank', 'location=no');

wow thank you… also can you help me on page load i want to open pdf in ionic.

This is kind of very difficult because if you directly open a link in your app then it does works, but the problem is that there is no way to go back as there is no back button. This is where inAppBrowser comes in picture having ‘DONE’ button.

Will recommend to use inAppBrowser for ur task, but yes there is chance that you open a Link inside iFrame providing custon UI to close iFrame etc… I didn’t tried iFrame in iOnic app tho :wink:

i used iframe pdf is opening in my laptop in browser when im doing ionic serve. but i installed apk in mobile it is not opening… can you help below my iframe and controller code.
in html page
<iframe ng-src="{{pdfurl}}" style="width:100%; height: 1100px;"></iframe>

in controller…
$scope.pdfurl =$sce.trustAsResourceUrl(‘’ + encodeURIComponent($scope.pdf));

How do you open local files on an android device.

@jswebtech have you finally found a solution about this ?

@jerrybels yes i got solution…

@jswebtech could you explain your solution?

@missile here is my controller…

.controller(“IncSalesPdfCtrl”, [’$scope’,’$http’,’$stateParams’,’$sce’,’$ionicLoading’,
function($scope, $http, $stateParams,$sce,$ionicLoading)
${ template: ‘Loading…’ })
var cid = $stateParams.DocKey
var incsalespurl='’+cid
$scope.salesrow = data.GetSalesDocumentResult;
$scope.pdfurl=$sce.trustAsResourceUrl(“” + $scope.salesrow.Path + “.pdf”);



You used the Google Docs renderer… That’s what I ended up with as well. Thanks

thank you for your code

I tried this example but it didn’t work in my android app when i click on that link nothing it showing just the same page itself it contains. please help me out

can u help me,
my pdf name Govt.pdf in ionic framework app i used it in html code its a link,
it will open when i run in browser because its present in img/ folder but after i install apk file into my mobile when i click the link it popups 'this file could not be access. check the locatio or network’
i understood it will bot download.
But i dont know how to do in ionic am new to ionic and angularJs can you help me come out of this…

did you find solution for this. i am also having requirement to not download pdf

I have tried but when i have installed the plugin i recive the error 404 from th link

nice!!! thank you!!! ios the best android bad)))

how to make it work in ionic3 ? i tried every method but all in vain