6

There are a million similar questions/answers, all addressing how to open a remote PDF file using Google Docs + webview.

None address how to open a local PDF file.

Given these strings:

String remotePath = "https://myserver.com/data/files/organization/4/pdf/kalinka1369-1374847709-55.pdf"; String localPath = "file:///storage/emulated/0/Droid Noid/com.story.chapters/kalinka1369-1374847709-55.pdf"; String googleDocsURL = "https://docs.google.com/gview?embedded=true&url="; 

This works:

webview.loadUrl(googleDocsURL + remotePath); 

Whereas this does not:

webview.loadUrl(googleDocsURL + localPath); 

I realize there is a space in localPath and I have tried encoding it to no avail:

String encodedLocalPath = "file:///storage/emulated/0/Droid+Noid/com.story.chapters/kalinka1369-1374847709-55.pdf"; 

Is it possible to open a local PDF file using Google Docs + webview? If so, how?

1
  • If it is acceptable to use something as adobe reader instead, I have code for that. I behaves nicely, going to fullscreen and returns to your app on backpress, though I can understand the value of having it embedded on the device. On the other hand it is ready immediately no matter the availability of internet access Commented Oct 1, 2013 at 15:03

1 Answer 1

9

Is it possible to open a local PDF file using Google Docs + webview?

Only if you upload the PDF somewhere on the Internet where Google Docs can access it, or perhaps arrange for somebody else to upload the PDF somewhere on the Internet where Google Docs can access it (e.g., Google Drive).

Sign up to request clarification or add additional context in comments.

5 Comments

Ha, okay well sounds like it's definitively not possible unless I make it a remote file. Thanks!
i was breaking my head over it..how to have a reliable url for my pdf files. Google drive is a damn good idea. ty :)
@commonsWare I've uploads my '.pdf' doc to google drive. It's link is something like this https://drive.google.com/file/d/0B0ecHy3Xov6tT0hINUZ5djRNZkk/view which is not of format http://www.abcd.com/sample.pdf. Now how should I open it in web view using google docs? If the general format is used then it would be https://docs.google.com/gview?embedded=true&url=https://drive.google.com/open?id=0B0ecHy3Xov6tT0hINUZ5djRNZkk
@Prabs: I have not used Google Drive for this. I would assume that you just replace the url parameter with your URL. There is nothing in the Drive URL that should be a problem as a query parameter value.
I'm sorry but I didn't understand what you are trying to say. could you kindly give an example with the above link if possible. what should be in loadurl. is it loadurl(myUrl) or anything else

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.