Home >Backend Development >PHP Tutorial >How Can I Make PDF Files Always Downloadable via HTML Links?
Make PDF Files Downloadable via HTML Links
When providing PDF file download links on a web page, you may encounter differing behaviors depending on the user's system configuration. To address this, follow these steps to ensure that PDF files always trigger download prompts, regardless of whether Adobe Acrobat is installed:
Solution:
Utilize the HTML5 attribute "download" within the anchor tag ( element):
<a href="./directory/yourfile.pdf" download="newfilename">Download the PDF</a>
<a href="./directory/yourfile.pdf" download>Download the PDF</a>
Compatibility:
Tested and confirmed to work in Firefox 21 and Iron. However, compatibility may vary in browsers that do not support HTML5 or have outdated versions. IE is known to not force downloads using this method.
For detailed compatibility information, refer to: http://caniuse.com/#feat=download
The above is the detailed content of How Can I Make PDF Files Always Downloadable via HTML Links?. For more information, please follow other related articles on the PHP Chinese website!