Display the pdf file(stored in google drive) in webview by using google docs

前端 未结 5 1192
半阙折子戏
半阙折子戏 2021-01-03 03:39

My pdf file is stored in some website ex: http://www.pdf995.com/samples/pdf.pdf

Now I can\'t rely on other websites for my app. So

  1. I\'ve downloaded th
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 04:08

    I was suffering from same problem and after a lot of hit and trials, I found a way out.

    You need to click on download button of google drive.

    as soon as you click it, a new tab will open with a different url, of this type

    https://drive.google.com/uc?id=0B1dndMpNP4zgdlTuMm5rcjFk3TQ&export=download //test url//

    String url="https://drive.google.com/uc?id=0B1dndMpNP4zgdlTuMm5rcjFk3TQ&export=download";
    webView = (WebView) findViewById(R.id.progr);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url="+url);
    

提交回复
热议问题