Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Document Viewer shows "No Preview Available"

I have used Google Document Viewer to open PDF files in my Android device. A black screen with "No Preview Available" text is shown, instead of opening my PDF files. I have tested with sample PDF files from Google. They are working fine, but not my PDF files. Is there anything that i need to do from code side to view my PDF.

http://docs.google.com/viewer?url=myurl.pdf

enter image description here

like image 773
msg Avatar asked Mar 07 '15 18:03

msg


3 Answers

Had a file that showed this problem. Renamed it to remove blanks in the file name, updated my link and it worked. Note that blanks were properly HTML encoded as %20 so this 'fix' shouldn't be necessary. But, I can't argue with success. Good luck.

like image 122
larry Avatar answered Nov 13 '22 15:11

larry


Finally solved this issue. Issue is there in url. In url I replaced %2 to %252 then after 1 week I solved this issue.

In short I want to encode query string.

if (Url != null && Url.contains("=")) {
    String Urll =Url.substring(Url.lastIndexOf("&Signature=") + 1).replace("%2B", "%252B");
    if (null != Urll && Urll.length() > 0 && Urll.contains("%252B")) {
        int endIndex = Url.lastIndexOf("Signature");
        if (endIndex != -1) {
            Url = Url.substring(0, endIndex);
            Url = Url + Urll;
        }
    }
    Url = Url.replace("?AWSAccessKeyId=", "?AWSAccessKeyId%3D")
            .replace("&Expires=", "%26Expires%3D").replace("&Signature=", "%26Signature%3D");
}
like image 34
Devilal Tank Avatar answered Nov 13 '22 15:11

Devilal Tank


Try encoding the url like this

    try {
            encode_url=URLEncoder.encode(url,"UTF-8"); //Url Convert to UTF-8 It important.
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

webView.loadUrl("https://docs.google.com/viewerng/viewer?embedded=true&url="+encode_url);
like image 25
44kksharma Avatar answered Nov 13 '22 14:11

44kksharma