Whoops! There was a …previewing this pdf document android

[亡魂溺海] 提交于 2021-02-18 16:40:10

问题


My application has a list of pdf inside listview. The pdf is viewed inside the application using a webview that open a Google Docs sheet. It works fine for the first opened PDF, but when going back and opening another PDF I got the error "whoops! There was a problem previewing this document". Is there some kind of limitation on opening PDF using google sheet. If so, how can I get full rights to open any PDF 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());

回答1:


Try increasing the Version/Compatibility of the PDF. This worked for me.

Edit: I believe it is more of a size issue. When I changed the Version (from Acrobat 9.0 to 10.0) I had also optimized the PDF making it a smaller file. My larger files of the same Version still do not work.




回答2:


I was having the same issue. What solved it for me was clearing the WebView cache 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);


来源:https://stackoverflow.com/questions/26864593/whoops-there-was-a-previewing-this-pdf-document-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!