0

i am trying to load pdf in webview from my sdcard but it gives message
"Sorry, we were unable to find the document at the original source. Verify that the document still exists!"

i also googled this but after banging my head a lot i got nothing than this one and this one ...

  webView = (WebView) findViewById(R.id.webview_compontent);
   fill_form = (Button) findViewById(R.id.fill_form);

   fill_form.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        Toast.makeText(getApplicationContext(), "In Progress", Toast.LENGTH_LONG).show();
    }
});


   webView.getSettings().setJavaScriptEnabled(true);     
   webView.getSettings().setLoadWithOverviewMode(true);
  // webView.getSettings().setUseWideViewPort(true);        
    webView.setWebViewClient(new WebViewClient(){

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            progDailog.show();
            view.loadUrl(url);

            return true;                
        }
        @Override
        public void onPageFinished(WebView view, final String url) {
            progDailog.dismiss();
        }
    });
 //   String fileurl = Environment.getExternalStorageDirectory()+File.separator +"pk.pdf";
    File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"pk.pdf");
    Uri fileurl = (Uri.fromFile(file));

    String Url = "http://docs.google.com/gview?embedded=true&url=" + fileurl;
    webView.loadUrl(Url);
}

Please give any idea how to do this ?(I don't want to use any payable rendering library.)

Community
  • 1
  • 1
dev_android
  • 493
  • 1
  • 11
  • 29
  • 1
    Unlike iPhone android 's webkit is not that strong, that it can open a PDF file. You need to use a third party library to open a PDF doc. I would recommend MuPDF library for viewing PDF files on android platform. – Tushski Nov 06 '14 at 12:34
  • this post help me https://stackoverflow.com/a/43087727/2416823. It works offline, without google pdf viewer! – user2416823 Aug 21 '17 at 14:03

1 Answers1

1

I don't think that webview can load a pdf for you. Sso you still have two options: 1. Try to ask other applications to view this PDF for you. 2. You can try this librarry https://github.com/JoanZapata/android-pdfview if GNU policy suits you.

Serge
  • 318
  • 3
  • 7
  • :( but tats the thing i wanted to do :( – dev_android Nov 06 '14 at 12:33
  • 1
    You can try contact google regarding this issue on WebView and ask them to include it in future releases. But you can try Library I have suggested its free on terms of GNU. – Serge Nov 06 '14 at 12:43