Is it possible to open pdf file storage in sdcard / cache in webview?

I am uploading a PDF file to my application and I want to allow the user to view it. Is it possible that with webview I can display this pdf file downloaded to SD card or local memory. As I know, there is a workaround where I can provide a pdf file link to google url that will open the pdf in webview. But it lags behind and is very slow.


source to share

2 answers

The main answer is no. You cannot open a PDF file in webview; so you either need to launch the Intent to open the file (the file can be opened in the default app on the device); or write your own PDF reader.



Try using pdf.js. See

I downloaded its source and put it in sdcard.
Then I use WebView

to download it index.htm


It was showing pdf in webView in sdcard on android 4.0 device but sometimes it shows white page. I need to reload it and it can finally show.

Unfortunately I also tested on Android 2.2 and 2.3 devices. They just show a white page, nothing. I know it uses html5 canvas technology. I checked when loading on WebView

and has a check mark on the canvas element but still can't show the pdf. Strange behavior. Perhaps it really depends on the Android version.



All Articles