SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    linking to a PDF file?

    I have just worked through Ian Lloyd's "Build your own web site the right way" and am now building a site (my first one and it is still on my hard drive).

    I began Fortran programming in 1962 but until now had not attempted web design.

    All files are in one folder. I have successfully linked to images (.jpg files). One file is sample.pdf and I want this to appear on one of the web pages. I am trying to do this using an anchor link but cannot get the pdf document to appear.

    What is wrong with this code?

    <p>The Board Members.
    <a href="sample.pdf"></a></p>

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,033
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    <a> is for creating a link to a document, not to embed it in the website.
    There is no method to embed a PDF file in your website afaik (at least not in a part of it. for full window embedding you need a scripting language that can modify HTTP Headers, and the user has to have a pdf reader installed).
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,179
    Mentioned
    234 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Allan Jamieson View Post
    I have just worked through Ian Lloyd's "Build your own web site the right way" and am now building a site (my first one and it is still on my hard drive).

    I began Fortran programming in 1962 but until now had not attempted web design.

    All files are in one folder. I have successfully linked to images (.jpg files). One file is sample.pdf and I want this to appear on one of the web pages. I am trying to do this using an anchor link but cannot get the pdf document to appear.

    What is wrong with this code?

    <p>The Board Members.
    <a href="sample.pdf"></a></p>
    There is nothing between the tags, therefore there is nothing where I can click to open that link. Your code should be as follows.

    Code:
    <p><a href="sample.pdf">The Board Members</a></p>
    In this way, the words "The Board Members" will be highlighted and I will have the possibility of clicking and opening the PDF.

    The PDF may download or show on screen, that depends if the browser has a PDF viewer plug-in installed. Most browsers nowdays do have that plug-in, but if the browser doesn't, it allows the user to save the file in his computer.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,788
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If you want to avctually embed the PDF into the web page rather than link to it you could use an <img> or <iframe> tag instead of the <a>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My sincere thanks to Molona for the simple "fix."

    My apologies to ScallioXTX and the others who replied: My inadequate explanation of what I wanted to do misled you but thanks for taking the time to reply anyway.

    I am learning!!

  6. #6
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,179
    Mentioned
    234 Post(s)
    Tagged
    1 Thread(s)
    Don't worry. Glad if we have been of help. I am learning too!

    Ah! and Welcome to SP!

  7. #7
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I want to point out that somewhere, somehow you will see something like your original code:
    <p>The Board Members<a href=blah.com"> </a></p>

    What you would do with this is, when you need there to be text ("The Board Members") available to image-disabled surfers (like teh googles or Dial-uppers) but, if the visitor has images on, sees only the image (which is only clickable). The image, contained in the a, would cover up the text, so long as the image didn't have any transparency. It's a nice trick to use when you need it and is appropriate:

    p {
    width: same as image:
    height: same as image:
    position: relative; /*establish a reference*/
    }
    p a {
    position: absolute;
    width: 100&#37;; /*of p*/
    height: 100%;
    top: 0;
    left: 0;/*you only need these coords when a is not the first child of the parent*/
    background: url(pdfimage.jpg) 0 0 no-repeat;
    }

    You can leave out the top and left part if you wrote the html like this:
    <p><a href="blah.com"> </a>The Board members</p>

    This would not give a clickable link to those using no CSS, because there's nothing inside the a to force a width, as without CSS it remains inline.

    But, it's good to know that you will see this. It's called Gilder-Levin image replacement and has saved my hide sooooo many times.
    Last edited by Stomme poes; Sep 23, 2008 at 23:37. Reason: Arrrg typo in code!

  8. #8
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I'm lucky that there are many people "above me."

    Allan


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
  •