Srinivasan
Srinivasan

Reputation: 4661

View PDF files in Android webview

How do I open a PDF file in my web view wihtout downloading and saving it to the SD card? I have done some R&D on this but until now I haven't got any appropriate answers. Can anyone tell me how to use googledoc to open the PDF file in the web view?

Upvotes: 2

Views: 3772

Answers (2)

Mike T
Mike T

Reputation: 4787

See the answer here

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

where webUrl is the url of the pdf you want to open.

Upvotes: 0

Anirudh Ramanathan
Anirudh Ramanathan

Reputation: 46788

http://docs.google.com/viewer?embedded=true&url=link_to_pdf will format your PDFs for you to open within the webview, using Google Docs Viewer.

WebView mWebView = new WebView(this);
mWebview.getSettings().setJavaScriptEnabled(true);  
String url = "http://docs.google.com/viewer?embedded=true&url="+"http://sitename.com/xyz.pdf";
mWebview.loadUrl(url); 

Upvotes: 6

Related Questions