1

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

Rene
  • 85
  • 1
  • 6
  • [this][1] [1]: http://stackoverflow.com/questions/25522864/loading-pdfs-into-the-android-webview/25523107#25523107 hope it ll help you...... – Vaishali Sutariya Aug 27 '14 at 10:30

1 Answers1

3
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);
Samir Mangroliya
  • 39,918
  • 16
  • 117
  • 134