Forum Moderators: phranque

Message Too Old, No Replies

Forcing a PDF to Download Rather Than to Open

Is this possible?

         

lebhead

6:08 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Hi all. I am developing a page that calls for a user to fill out a form. Once the form is submitted, I want a PDF to automatically start downloading rather than open. The reason for this is because I know that some people's browsers are configured to open the PDF in a browser window, while others will download it and open it in a helper app, and others will simply download it to disk. This is especially important since there will be a significant number of Mac browsers visitng the page. I want consistancy, so I figured it would be best to simply force a download - if it is possible, that is.

The flow would be similar to CNET's download.com. You click the "submit" link (in my case it would be a form submit button) and you are taken to a "thank you" page, which says "your download has begun... if not click the link below... ", while the PDF download begins.

Is this possible, or will the user's browser settings always be set in stone? I do not want to ZIP the PDF.

---

(sorry if this thread is in the wrong place - I couldn't decide between this one or the HTML board. please move this thread if it's in the wrong place)

jamesa

6:23 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yea, it's in how you send the headers. Check out this page [us4.php.net] in the PHP manual. The last example right before the user contributed notes shows you exactly how to do it. If you're using a different language, this will still help and you'll just need to find the syntax for sending headers for the language you're using.

lebhead

6:41 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Thanks! I'll be using ASP or CF for this, but I get the general idea about the headers. =)

The only thing that slightly concerns me is the part about the IE 5.5 bug. Either way, if this doesn't pan out I guess I can always make the thank you page redirect to the PDF file. That way at least the people who can view PDFs in browser will see the file and the others will see a download box with the thank you page still displaying in the browser window.