How to open a PDF file and watch on the device for both iOS and Android

I have one pdf address. When I try to open its work in the browser. But when I try to open both Android device and ios. My pdf file does not open. Here is my code:

My controller:

$window.OpenLink = function(link) { window.open( link, '_system'); }; 

My html code is:

 <div class="col col-50 clsGrid" onclick="OpenLink('http://www.orimi.com/pdf-test.pdf')"> 

Please help me. How can I open a pdf file and see both on an Android device and on ios.

Thanks in advance!

+7
html angularjs pdf ionic-framework hybrid-mobile-app
source share
2 answers

install plugin

 cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git 

try it

 <a class="item" href="#" onclick="window.open('http://www.orimi.com/pdf-test.pdf', '_system', 'location=yes'); return false;"> Open pdf </a> 
0
source share

A similar question is asked here. Ionic structure PdfViewer

Try using this Phonegap plugin https://github.com/ti8m/DocumentHandler This worked fine for me.

The following shows how I integrated it.

 $scope.HandleDocumentPlugin = function () { if (DocumentViewer != null) { DocumentViewer.previewFileFromUrlOrPath( function () { console.log('success'); }, function (error) { if (error == 53) { console.log('No app that handles this file type.'); var alert = $ionicPopup.alert({ title: 'Alert!', template: "There is no app installed that handles this file type." }); alert.then(function (res) { }); } }, $scope.PDF_URL); } else if (DocumentHandler != null) { DocumentHandler.previewFileFromUrlOrPath( function () { console.log('success'); }, function (error) { if (error == 53) { console.log('No app that handles this file type.'); var alert = $ionicPopup.alert({ title: 'Alert!', template: "There is no app installed that handles this file type." }); alert.then(function (res) { }); } }, $scope.PDF_URL); } else { console.log("error"); } } 
0
source share

All Articles