How to open a remote PDF with Ionic?


#1

Hi all,
I’d like to open a PDF (or just download it) from an Ionic App (Cordova 1.5.0 - Ionic CLI 3.6.0).
I’ve found many posts on that argument but I can’t find a nice solution.

I’ve tried:

this.iab.create(pdfUrl, "_self", "location=yes,hidden=no");
this.iab.create(pdfUrl, "_blank", "location=yes,hidden=no");
window.open(pdfUrl, '_self', 'location=yes');
window.open(pdfUrl, '_blank', 'location=yes');

window.open(wsUrl, '_system', 'location=yes');

The first 4 commands do not work, don’t open the PDF.
The last command downloads the file but opens the system browser on a page (I suppose the last visited) that has nothing to do with the wsUrl and the effect is not professional.

So, the question is always the same, is it possible to open a PDF with Ionic?

Thank you very much.

cld


#2

You need to install a pdf viewer for Angular 2 (4). First hit on my Google search was this:

But I’ve never used it. “Angular 2 npm pdf” is the search term you probably want. Probably your best bet is to try out a fe different libraries until you find something you like.


#3

Try this.


#4

Yes this solution works well.
Thank you very much.
cld


#5

Thanks for the solution, I tried your method, its working fine in browser but not mobile device. what might be the issue?