0

How to open the pdf in a Webview android studio

this is my pdf

String pdf = "http://192.168.1.181:8081/reports/RepoActivityLog181.pdf";

and this is my code

wvPDF.getSettings().setJavaScriptEnabled(true);

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

        wvPDF.setWebViewClient(new WebViewClient() {
            public void onPageFinished(WebView view, String url) {
            }
        });

    }
  • Seems you are using local ip to access your pdf file. So i think you can not use your local ip with Google Docs url. – Ajay Mehta Apr 19 '19 at 09:54
  • 1
    Possible duplicate of [How can I display a pdf document into a Webview?](https://stackoverflow.com/questions/2655972/how-can-i-display-a-pdf-document-into-a-webview) – ADM Apr 19 '19 at 10:15
  • Have you internet permission? If you have internet permission I think you have a problem with local ip of your pdf. – Andres Rivas Apr 11 '20 at 17:59
  • Try encoding the url before loading it, check here https://stackoverflow.com/a/67245546/1843984 – 44kksharma Apr 25 '21 at 09:27

0 Answers0