Android Studio webView PDF is showing <IFRAME> and not pdf

1k views Asked by At

i am trying to fetch PDF in PDF but in result i am getting

ERROR

<iframe width="100%" height="1000" src="https://ns3.creativerp.org/kbm/web/tcpdf/print/generated_form1.php?id=K33228501" ></iframe>

xml

   <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /> 

Java class

String url = "https://khanienclave.com/verify.php?id=K33228501";
        
        webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + url);

        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setAllowFileAccessFromFileURLs(true);
        webview.getSettings().setAllowUniversalAccessFromFileURLs(true);
        webview.getSettings().setBuiltInZoomControls(true);
        webview.setWebChromeClient(new WebChromeClient());
1

There are 1 answers

0
snachmsm On

WebView is desired to show web content, not (PDF or any other format) document. this site you are opening is in fact a web app which can render PDF file as web content, so you are obtaining an iframe

you can find pleny of PDF-rendering libraries for Android, e.g. probably most common AndroidPdfViewer, but in THIS article you can find more alternatives