Jose Cabrera Zuniga
Jose Cabrera Zuniga

Reputation: 2613

is it possible to make an hyperlink to only download a pdf file?

I have an hyperlink to a pdf form that can not be opened by the browser's pdf viewer. If clicked, the browser tries to show it but I get the error message like "it is necessary Acrobat Reader 8.x" etc. Is there a way to force an hyperlink to such pdf form file to only allow its downloading? In this way, the user could open it with his local Adobe Reader.

Upvotes: 1

Views: 2685

Answers (3)

Dave Crouch
Dave Crouch

Reputation: 1

Does this work also for word documents as the code you provided does not download the file.

<a href="assets/document/SF_02A_APPLICATION_FORM.docx" download="SF_02A_APPLICATION_FORM.docx">

Download Application

This is what I use, when testing it it says failed (on chrome) couldn't download (on Edge) and opens up a blank screen on firefox.

It is pointed to the file path.

Upvotes: 0

Fiad
Fiad

Reputation: 803

Let’s say you have a PDF that you want to let people download. The file will be like this:

<a href="/path/to/your/receipt.pdf">Download Receipt</a>

In most browsers, clicking on the link will open the file directly in the browser.

But, if you add the download attribute to the link, it will tell the browser to download the file instead.

<a href="/path/to/your/receipt.pdf" download>Download Receipt</a>

The download attribute works in all modern browsers, including MS Edge, but not Internet Explorer.

In the latest versions of Chrome, you cannot download cross-origin files (they have to be hosted on the same domain).

Upvotes: 4

Vibhor Goyal
Vibhor Goyal

Reputation: 110

To make the hyperlink to download the pdf file when clicked, you should use download property inside the anchor tag. For example you can see the code below:

 <a href=".document/doc1.pdf" download="Document">Download the pdf file</a>

You can also give your own name to the downloadable pdf file in the download property that I provided as 'Document' in the code above.

Upvotes: 2

Related Questions