Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Phonegap open PDF file

How to open PDF file without plugin? I'm tried : window.open(path, '_blank', 'fullscreen=yes'); and opened blank page in editor.

like image 974
Esti M Avatar asked Oct 20 '22 23:10

Esti M


1 Answers

Do you want the PDF to open inside your app, or is it OK if it's opened externally? If it's the latter:

  • On iOS you can just create a normal link with target="_blank" and Phonegap will open the pdf in Safari.

  • On Android you need to call window.open with "_system" as window name: window.open("yoururl", "_system", "location=no"); and Android will either open in the browser or start downloading (which might not be very obvious), or show the "Complete action using"-dialog if there are several options to open the file.

Of course, the downside of opening externally is that the users need to get back to your app themselves after viewing the PDF, so if you anticipate many users will view the pdf I would not recommend this solution.

like image 69
Strille Avatar answered Nov 02 '22 06:11

Strille