I am downloading PDF file in my application and want to allow user to view it. Is it possible that using webview I can display that pdf file downloaded to SD Card or local memory. As I know there is workaround in which I can provide the link of pdf file to google url which will open pdf in webview. But it lags and is very slow.
-
See: http://stackoverflow.com/a/4766335/165674 – Dheeraj Vepakomma Mar 29 '12 at 14:23
-
1Did the answer below answer your question? – HaemEternal Apr 04 '12 at 09:49
2 Answers
Basic answer, no. You can't open a PDF in a webview; so you either need to fire an Intent to open the file (the file can then open in the default installed app on the device); or write your own PDF reader.

- 2,229
- 6
- 31
- 50
-
:( making own pdf reader is the main issue. I have used Jblough Android PDF Viewer Lib from GitHub. But the problem is that it opens in new activity, I want to show it inside my layout. – Adil Bhatty Mar 29 '12 at 14:22
-
It's a common problem unfortunately. There's a lot of questions on here already that may be able to advise you, but eventually you'll either need to settle for a seperate app, or write your own. Theres a few open source projects you could look at for a starting point. These links may help you get a little further research: http://stackoverflow.com/questions/6079923/open-pdf-in-android-app http://stackoverflow.com/questions/5617391/how-to-develop-a-pdf-reader-in-android http://stackoverflow.com/questions/5113435/invoking-adobe-reader-from-within-my-android-application – HaemEternal Mar 29 '12 at 15:27
Try to use pdf.js. See http://www.worldwidewhat.net/2011/08/render-pdf-files-with-html5/
I downloaded its source and placed it in sdcard.
Then I use a WebView
to load its index.htm
.
It did show pdf file on a webView in sdcard in Android 4.0 device but sometime it show white page. I need to reload it and it finally can show.
Unfortunately, I also tested on Android 2.2 and 2.3 devices. They just show white page, nothing.
I know it make use of html5 canvas technology. I have checked on loading http://html5test.com/ on WebView
and have tick on canvas element but still can't show pdf. Strange behaviour. Maybe really depends on Android version.

- 2,202
- 2
- 27
- 50