Oops! Was ... viewing this PDF document android

My application has a pdf list inside a listview. The PDF is viewed inside the app using webview, which opens the Google Docs sheet. It works fine for the first PDF opened, but I got the error when returning and opening another PDF "whoops! There was a problem previewing this document"

. Are there any restrictions on opening PDF with google sheet. If so, how can I get full rights to open any PDF file I want. can someone help please. Here is my code.

    //---you need this to prevent the webview from
    // launching another browser when a url
    // redirection occurs---
    wv.setWebViewClient(new Callback());
    wv.getSettings().setJavaScriptEnabled(true);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.getSettings().setAllowFileAccess(true);

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

      

+3


source to share


2 answers


Try increasing the PDF version / compatibility. This worked for me.



Edit: I believe this is more of a size issue. When I changed the version (from Acrobat 9.0 to 10.0), I also optimized the PDF, making it a smaller file. My large files of the same version still don't work.

+1


source


I had the same problem. For me, this resolved to clear the cache WebView

before trying to load another PDF.



WebView webView=(WebView)findViewById(R.id.webView);
webView.clearCache(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://docs.google.com/viewer?url=" + url);

      

0


source







All Articles