SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Adding PDF file

  1. #1
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    418
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Adding PDF file

    Okay, forgot something I used to know...

    How do I add a PDF file (newsletter) to my website. I tried the <a href="images/xnndnd.pdf" but that apparently is wrong.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,323
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Yes, you just need to create a link and make sure it points to the right location and file. So this—

    Code:
    <a href="images/xnndnd.pdf">View PDF</a>
    —will work if:

    - the pdf is in your images folder
    - the images folder is in the same folder as the page the link appears on
    - the name of the PDF file is xnndnd.pdf

    It's generally easier to put your images folder in the main site folder (the 'root folder', where your home page is) and then link to the images folder from any page on the site with

    Code:
    <a href="/images/xnndnd.pdf">View PDF</a>
    Then you don't have to worry about the location of your page in relation to the location of the images folder.

  3. #3
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    418
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    So why doesn't this work?

    <center><a href="images/Midwest.pdf" height="200" width="200"></center>

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,323
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    You have an incomplete link there. You need some text for the link to appear, something like this:

    Code:
    <center><a href="images/Midwest.pdf">View PDF</a></center>
    You don't put width and height on an <a>, just on an image. So if you want people to click on an image rather than a text link, you'd need to create an image of your PDF (you could take a screen shot, for example) and then use code like this:

    Code:
    <center>
      <a href="images/Midwest.pdf">
        <img src="images/pdf-pic" width="200" height="200">
      </a>
    </center>
    So the link point to the pdf, which will open the pdf when they click on it, but what the user sees before hand is an image of the PDF.

    You can't just have an empty link like <a href="">. Look at the code for any links on your site. None of them are empty like that. You need a closing </a> tag, with text in between that becomes the linked text. Images are different in this respect.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •