Avinash Kumar
Avinash Kumar

Reputation: 787

ionic v1 open pdf using inappbrowser and pdf.js

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

Answers (2)

Khurshid Ansari
Khurshid Ansari

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

sunil kalwani
sunil kalwani

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

Related Questions