简体   繁体   中英

How to open external pdf in Android with Ionic

I am working on an application, and I am facing a problem with Ionic1 , and it concerns opening a .PDF from an external URL in Android with Ionic. I tried many solutions given in this site and other sites but in vain. this is an example of what I have tried:

in .html file:

<a class="item" href="#" onclick="window.open('http://www.xxx.pdf', '_system', 'location=yes')">

in .js file:

var ref = window.open('http://www.xxx.pdf', '_blank', 'location=yes'); 

can you suggest other solutions please?

You could use the cordova inapp browser plugin .

you can replace all window.open by inappBrowser;

window.open = cordova.InAppBrowser.open;

or you can just use:

cordova.InAppBrowser.open('http://linktopdf.pdf', '_blank', 'location=yes');

or if you use ngCordova, you can use $cordovaInAppBrowser,

$cordovaInAppBrowser.open('http://www.xxx.pdf', '_blank', options)

take a look here: http://ngcordova.com/docs/plugins/inAppBrowser/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM