But what if we need is to have the pdf to automatically be downloaded once we click the link? One approach that I have tried is to use a javascript that would enforce downloading of the pdf instead of loading it, yet the problem
with javascript is, if it was disabled on the users browser preference making the pdf link broken.
The solution that I have found is via .htaccess.
If your hosting allows you to use .htaccess files, add this directives into the .htaccess at the folder with your PDF-files:
ForceType application/octet-stream
Header set Content-Disposition attachment
Header set Content-Transfer-Encoding binary
This prevents loading the pdf’s into the browser.
N.B.
Make sure the LoadModule headers_module modules/mod_headers.so is loaded on your apache config file
or you will get "Invalid command 'Header'" error
you have great idea :D dheluxe@yahoo.com
ReplyDelete