Hetal Vora
Hetal Vora

Reputation: 3361

PhoneGap Android app not displaying pdf data

I have a PhoneGap app for Android which I am trying to run in the Android emulator. The app has a simple html page which has a button. On click, the button calls a RESTful webservice using javascript XMLHttpRequest and the service returns back base 64 encoded data for a pdf. Then from the javascript function, I try to load the pdf data in my html page in the app as below

document.location.href = 'data:application/pdf;base64,' + pdfData.childNodes[0].data;

But this does nothing. The data is returned correctly and I checked the logs for it. But the pdf is not displayed at all. Any idea what is causing the issue?

Upvotes: 2

Views: 22951

Answers (1)

Hanh Le
Hanh Le

Reputation: 894


In Android you not show pdf file in Webview. Have some solution to view pdf file in Android:

  1. Use google pdf view

    mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo_pdfFile);

  2. Download pdf file and view by pdf reader in device. Check this

  3. (My solution) I parse pdf file to image and store onto server and i only download and view image directly.(It have bit complex, but you can view pdf, docx, xls,..). Example here

Upvotes: 0

Related Questions