Reputation: 85
I am trying to use the Google Docs gview to load a pdf in my webview. It is loading the viewer but the pdf page itself is not shown. I have used this technique with other projects (other target url's) without any problem but I can not get the Google Docs Gview page to work with this. I use
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
HttpHelper httphelper = new HttpHelper();
String pdf = "https://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
String result = httphelper.GetPage(Uri.parse("https://docs.google.com/gview?embedded=true&url=" + pdf));
webview.loadDataWithBaseURL("https://docs.google.com", result, "text/html", "utf-8", "https://docs.google.com");
}
Any idea why this is not working with the gview page?
Thanks
Upvotes: 1
Views: 5350
Reputation: 40416
mWebview.getSettings().setJavaScriptEnabled(true);
String strPdf="https://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
mWebview.loadUrl("https://docs.google.com/gview?embedded=true&url=" + strPdf);
Upvotes: 3