3

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.

2

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

:( 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.
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: stackoverflow.com/questions/6079923/open-pdf-in-android-app stackoverflow.com/questions/5617391/… stackoverflow.com/questions/5113435/…
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.