View Full Version : how to... click hyperlink to download a PDF file

Oct 2nd, 2009, 12:39 AM
i wish for my visitors to click a hyperlink to download a PDF file instead of the right click and 'save as' or open PDF and then click save in the PDF window.

how can i do this.

Oct 2nd, 2009, 06:23 PM
tried an anchor tag yet?

<a href="http://yourdomain.com/pdf_file_name.pdf">pdf download</a>

their Browser settings will determine what to do with the file. You can't control that.

Oct 2nd, 2009, 06:39 PM
their Browser settings will determine what to do with the file. You can't control that.
No. There are some ways to do.
One way is to write some server side code in a file and specify the location of the file to be downloaded(either dynamically or statically, depending upon the requirement). You may view how to do this in php at http://php.net/ => Example #1

Another way is to directly link the anchor to the pds file and then configure your httpd.conf/.htaccess file(in apache, and there may be alternative in others too). Say, by adding the following line in your htaccess file, you'll get the result.

AddType application/octet-stream .pdf

Oct 3rd, 2009, 01:47 PM
ok i have tried and tried to get this to work and still not working the same in both FireFox and Internet Explorer.

in IE the page should all ok with the PDf imbeded in the page in the left hand side of my two table set.
and the download link shows and when clicked i get a download box to download my web page file in view not the PDF file.

in FireFox the reverse happens, the PDF does not show in the table (the PDF is open in a PDF viewer, acrobat) and the download box shows the correct file to be downloaded being the actual PDF file.

here is the page that i am working from...

www dot rra dot realistic (takeout space) hostings dot com

can anyone see why i have both browsers doing different things.

IE is doing what i want to have happen in both if i can. it allows you to click the download link to get the download box to the correct file the PDF file.

but FF seems to open the PDF in its own PDF viewer acrobat, how can i get the file to forcely open in the tables.

i tried to use this....

AddType application/octet-stream .pdf

but that did not work either.

any other ideas, cheers

Oct 3rd, 2009, 09:36 PM
How many pages does your .pdf file contain? If it is only a single page (like a page or press-release) you can convert it to a .jpg file and use image mapping with a thumbnail. I have used one here (site still under construction). I think that multiple pages would have to be downloaded, but I haven't grappled with that question yet...


Oct 3rd, 2009, 09:46 PM
that was one option that i have been told to do to convert to JPG but this is not an option as i need the search engines to grab the text from the page as well and they would not from the image.

i have looked at this site... phpclasses.org but they do not seem to have a PDF2HTML but did have the reverse a HTML to PDF so i really need to find some way to do this the other way from PDF to HTML.