4

I am working on an android app which should be able to show pdfs in the app. I am using google docs viewer to show pdf. But the problem I face while using google docs viewer is, it is showing a thick border around the document and also a toolbar which has zoom and other controls on it. Is there any way to remove the border and the tool bar such that all the screen space is occupied by only the pdf doc.

Thanks..

Sampath Pasupunuri
  • 628
  • 1
  • 13
  • 25

2 Answers2

4

The answer could be found in this link to a similar Stack Overflow issue. If you are using a Web View to present the URL to the pdf file, then you should check the following:

  • Google Docs viewer before your URL: https://docs.google.com/viewer?url=
  • Embedded parameter: embedded=true

So, if the URL to the .pdf file is http://my.urlto.pdf then, in order to be previewed using Google Docs Viewer via the Web View component, you should have the following:

https://docs.google.com/viewer?embedded=true&url=http://my.urlto.pdf

This way you can preview the file without the toolbar.

0
webview.setWebViewClient(new WebViewClient() { 
            @Override 
            public void onReceivedError(WebView view, int errorCode,
                                        String description, String failingUrl) {

            } 

            @Override 
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true; 
            } 

            @Override 
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                webview.loadUrl("javascript:(function() { " + 
                        "document.getElementsByClassName('ndfHFb-c4YZDc-GSQQnc-LgbsSe ndfHFb-c4YZDc-to915-LgbsSe VIpgJd-TzA9Ye-eEGnhe ndfHFb-c4YZDc-LgbsSe')[0].style.display='none'; })()"); 
            } 

            @Override 
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);

            } 
        }) 
Android Tutorial
  • 829
  • 1
  • 8
  • 20