Trigger Save As… Window for PDF Download

February 16th, 2012 by Mark Lewis

Most browsers are equipped to display PDFs. This means when a user clicks on a link to a PDF on a website, the browser will download and display it. PDFs, however, are intended to be downloaded and retained by the user for offline viewing or printing.

It is possible, however, for anyone to save the PDF from the browser. You can right-click or ctrl-click on the link to the PDF and save the file to the local computer. If the PDF is already displayed in the browser, a Save As… menu option will allow you to save it locally as well.

To force the download of the PDF, or any other file, you need to send the content-disposition HTTP header. Most server-side programmers send content-disposition and location HTTP heades from their scripts. You can also configure Apache to send the content-disposition header for PDFs (or any other files).

<Files *.pdf>
ForceType application/pdf
Header set Content-Disposition attachment

This can be placed in your <VirtualHost> configuration.