Reputation: 787
i am trying to open pdf in ionic-v1 app.
I want to keep all pdfs on server and parse it will pdf.js file.
pdf.js will be at server ( not in mobile app). pdf.js uses <>.html file to show pdf file.
I want to use inappbrowser to open this server html file and show pdf.
Will this work? Please help.
Upvotes: 3
Views: 687
Reputation: 5095
1) Install cordova inappbrowser plugin:
cordova plugin add cordova-plugin-inappbrowser
2) Open pdf in inappbrowser:
function openMyPDF(){
let pdfUrl =
encodeURI("https://ionicframework.com/files/Ionic2Migration.pdf");
var ref = cordova.InAppBrowser.open(pdfUrl, "_blank);
}
Note : encodeURI() on this if the URL contains Unicode characters. encodeURI really helpful.
Upvotes: 3
Reputation: 826
install plugin
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
then try this
<a class="item" href="#" onclick="window.open('http://www.orimi.com/pdf-test.pdf', '_system', 'location=yes'); return false;">
Open pdf
</a>
Upvotes: 0