2

Just noticed that this question appears to have been incorrectly migrated to SuperUser.com:
How to instruct Chrome to download PDF rather than (pre)view in browser?

I would agree that if you simply look at the question title it looks like a question about Chrome, but the first line of the question suggests otherwise:

I have PDF file for download by users on my website.

The solution is programming related. In fact it is to do with the HTTP response headers and could perhaps be solved using .htaccess, which is on topic for Webmasters.

  • 1
    I agree that that would have been on-topic here. I'm not sure there is a way to get it back though. – Stephen Ostermiller Jan 24 '15 at 12:04
  • Yeah, it was really just a "heads up". I wasn't aware that it could be "sucked back", unless maybe it was sent back? – MrWhite Jan 24 '15 at 12:37
2

Initially the question looked to be solvable by modifying the headers, so I left a comment with some related suggestions. However, after further comments from the OP as to what was tried, some testing I tried (see below), and with the help of an answer from user Helping Hands (that got deleted by the system automatically after the migration, but appears on the Super User site), it appeared the issue is specific to Chrome's Chrome PDF Viewer plugin, which is installed and enabled by default. This is also confirmed in the answers to DisgruntledGoat's question on Super User here.

Prior to migrating, I tried modifying the header and MIME type, which worked for other browsers, but not for Chrome. Disabling the Chrome plugin solved the issue though. Therefore since the question was specific to the function of a particular web browser, and as indicated in the list of things considered off-topic here (i.e., the usage of web browsers), I migrated it to Super User where it could receive more attention and was a better fit.

If there was a programming solution possible, as the OP later commented they were thinking about using JavaScript in attempt to solve, that too would be considered off-topic here, so I suggested the OP post another question regarding that on Stack Overflow.

  • Although this was a question from a webmaster about offering a file for download to their users, not a user wanting to download a file from a another website (which would indeed be suited to SuperUser). Only a programming solution would be acceptable in this situation, so it should either have been migrated to SO, or indeed stay here. If a programming solution is not available then there is no solution. However, this is entirely solvable by modifying the headers... HelloWorld.pdf (Works for me in Chrome, Windows with Chrome's PDF viewer enabled). – MrWhite Jan 24 '15 at 16:32
  • As it is, the question is not specifically asking for code, or provide any code that was tried, so it would not be a good candidate for migration to SO, which is why I suggested the OP post another question there. It's still opening in my browser. You can of course post whatever you think would work on Super User too. – dan Jan 24 '15 at 17:58
  • Also, you might note that our Help Center document on What topics can I ask about here currently states: Usage of web browsers and other software - Super User is available for questions about how to use software in ways that are not directly related to running your own website. How one specific browser responds to a file doesn't seem to be directly related to software for running a website. I can see similar questions have historically also been migrated to Super User as well. – dan Jan 24 '15 at 18:20
  • Yeah, I didn't think it was a particularly great question. The OP has now answered there own question... "support staff have done something for me server side so it works now." - so it looks like we'll never know unfortunately (although they were running nginx which would explain the .htaccess failure). "It's still opening in my browser" - now I'm curious, are you referring to my HelloWorld.pdf example above? I've tried this on 3 machines now (Chrome on Windows and Chrome on Android) and a download is forced every time. Are you non-Windows? – MrWhite Jan 24 '15 at 18:46
  • That further complicates things since Nginx is often used as a proxy server, in which case the web server's headers might not be passed through to client browsers. That can also be the case with CDNs, and for clients connecting to sites through an intranet proxy server, like I was when I checked the link (Windows 7 64bit), though I also tested this earlier using a local installation on Linux. I think this is why we avoid troubleshooting sites and specific browser issues here. There's more users reporting issues with browsers on Super User, so I think that's the best place for this. – dan Jan 25 '15 at 5:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .