1

I downloaded a PDF into my Directory /storage/sdcard/.../example.pdf. Now I want to open it in the InAppBrowser from Phonegap.

var blaPath = fileEntry.fullPath.substring(7);
window.open(encodeURI(blaPath), '_blank', 'location=yes');

If I dont delete the first 7 chars (File://) from the Path, the InAppBrowser opens but it stays white. I heard, that I have to delete these chars for Android.

But when I delete them, i get a Site not found under the

Path: file:///android_asset/www//storage/sdcard0/.../example.pdf

How do I open a external PDF via InAppBrowser correctly?

Update: On further research I found this:

Could it be, that it is not possible to view a PDF via InAppBrowser on Android???

Update 2: Android doesnt seem to have a native PDF Viewer. I used a PDFViewer Plugin I wrote to open a PDF on installed PDF Reader.

allwynmasc
  • 393
  • 5
  • 18

1 Answers1

0

This is a little confusing: In your headline you say you want to open a pdf from a local directory but in the description you want to open an external pdf.

If the file is located on a server you can open it via the inappbrowser like this:

window.open(encodeURI('https://docs.google.com/gview?embedded=true&url=http://www.mydomain.com/files/your_file.pdf'), '_blank', 'location=yes,EnableViewPortScale=yes');

Otherwise, if you want to display a local pdf try: PDF.js or this

Omnicon
  • 314
  • 2
  • 9
  • I am not sure if they (Phonegap, Android) updated this in the meantime. But at the Time I wrote this post, it was not possible to open a PDF in the InAppBrowser, because the Android Webkit didn´t support to open PDFs. On the other Hand, the PDFs should be also accessible in Offline Mode. Also...the local Directory for Android Devices IS the external Storage. –  Feb 12 '14 at 10:42
  • Hey, I found a solution which I posted in another thread already. Hope it helps! http://stackoverflow.com/questions/17271052/phonegap-how-to-download-and-open-pdf-file-in-android-app/20965308#20965308 – Omnicon Feb 13 '14 at 02:31