Download PDF to webview using Google Docs gview

I am trying to use Google Docs gview to upload a PDF file to my webview. It loads the viewer, but the pdf page itself is not displayed. I used this technique with other projects (other destination URLs) without any problems, but I can't 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?

thank

+1
source share
1 answer
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);
+2
source

All Articles