The link above downloads the PDF, but I just want it to open up in the browser. Is there a way to do this?
Asked
Active
Viewed 2,915 times
3 Answers
1
If you want to open pdf in browser without downloading pdf then below is the best way to do it :
Intent i = new Intent(Intent.ACTION_VIEW);
String yoururl = https://spreadsheets.google.com/spreadsheet/pub?key=0Ap6NKDUcJz8sdHZjOWM1bkFxZ0wxUW9Bcnl3QmRsbGc&single=true&gid=0&output=pdf;
yoururl= "https://drive.google.com/viewerng/viewer?embedded=true&url=" + yoururl;
i.setData(Uri.parse(yoururl));
startActivity(i);

KishuDroid
- 5,411
- 4
- 30
- 47
1
Remove the output=pdf.

Arthur Frankel
- 4,695
- 6
- 35
- 56
-
You can use the viewer: https://docs.google.com/viewer for example: http://docs.google.com/viewer?url=https%3A%2F%2Fspreadsheets.google.com%2Fspreadsheet%2Fpub%3Fkey%3D0Ap6NKDUcJz8sdHZjOWM1bkFxZ0wxUW9Bcnl3QmRsbGc%26single%3Dtrue%26gid%3D0%26output%3Dpdf but I think you are talking about the browser using the pdf viewer. – Arthur Frankel Jul 07 '11 at 23:43
-
I guess that could work, but yes I want the browser to open it. – Mike Flynn Jul 07 '11 at 23:48
-
which browser are you using (or your users will be using)? – Arthur Frankel Jul 08 '11 at 00:16
-
I think the best you can do is download an addon: https://addons.mozilla.org/en-US/firefox/addon/google-docs-viewer-pdf-doc-doc/ – Arthur Frankel Jul 09 '11 at 14:11
-
What about Internet Explorer? – Mike Flynn Jul 11 '11 at 20:12
-1
If you want it to open in your browser, you need a PDF viewing plugin for your browser. The same obviously holds true for your visitors as well. It is the browser which determines what to do with files. (open or dowload)

damon
- 1,087
- 9
- 12
-
That is not true. You can either download or view the file. It depends how it is sent to the browser. I have Firefox and I can open PDFs. – Mike Flynn Jul 09 '11 at 04:31
-
It absolutely IS true. You can open PDFs in Firefox because you have a plugin. http://support.mozilla.com/en-US/kb/Opening%20PDF%20files%20within%20Firefox – damon Jul 09 '11 at 04:58
-
Your question is also a duplicate. http://stackoverflow.com/questions/6293893/how-to-force-pdf-files-to-open-in-browser – damon Jul 09 '11 at 05:09
-
I wasn't referring to the plugin part, but was referring to the the last sentence. The browser does not determine what to do with it. You can send a response back of bytes which would download or display the pdf (depending if they have the plugin). "content-disposition:attachment" would save, while "content-disposition:inline" would display on the response. Google is sending back bytes for an attachment causing me to save it, but I need it to send it back "inline" to display. – Mike Flynn Jul 11 '11 at 18:23