display pdf

Discussion in 'Programming' started by wasis, Sep 11, 2009.

  1. #1
    i want to display pdf file in my web, but my script is not working. here it is the script:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <INPUT id="btnopen" type="button" value="open report" name="Button1" onclick="location.href='pdf-php-tutorial-06.pdf'">
    </body>
    </html>

    this one is the another one:

    <html>
    <head>
    <script type="text/javascript">
    function showHideElement(element){
    var elem = document.getElementById(element);

    if (elem.style.display=="none"){
    elem.style.display="block"
    }
    else{
    elem.style.display="none"
    }
    }
    </script>
    </head>
    <body>
    <div style="position:absolute;height:100px;width:100px;background-color:Yellow;" onclick="showHideElement('Iframe1');">click me</div>
    <div style="position:absolute;z-index:100;background-color:Green;height:100px;width:100px;margin-left:200px;"></div>

    <div style="position:absolute;z-index:20;margin-left:200px;">
    <iframe visible="true" id="Iframe1" height="100" width="100" runat="server" frameborder="0" scrolling="auto" >

    </iframe>
    </div>

    <div style="position:absolute;z-index:10;margin-left:100px;">
    <iframe visible="true" id="ipdf" src="pdf-php-tutorial-06.pdf" height="1000" width="1000" runat="server" frameborder="0" scrolling="auto" >

    </iframe>
    </div>

    </body>
    </html>

    both of that script is not working, please help me to fix it..!
     
    wasis, Sep 11, 2009 IP
  2. new-media

    new-media Peon

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    are you trying to embed a pdf in your site? i.e. not as a download?

    what server you running apache or windows?
     
    new-media, Sep 12, 2009 IP
  3. gclass

    gclass Active Member

    Messages:
    337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Hi

    use this line, replace FILENAME with your file name and play with the zeros to hide/display controls.

    <embed src="FILENAME.pdf#toolbar=0&navpanes=0&scrollbar=0" width="500" height="375">
     
    gclass, Sep 13, 2009 IP
  4. ohteddy

    ohteddy Member

    Messages:
    128
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #4
    From a usability standpoint I would suggest you use a standard <a href> link to the pdf. With more and more eBooks these days, users may just decide to download it and read it on the train/bus. If you use an embed tag then you're requiring users who want to download your pdf to know how to view source and find the correct link to download. Besides, most browser know what application to use when opening a pdf anyway.

    Just my 2-cents...
     
    Last edited: Sep 13, 2009
    ohteddy, Sep 13, 2009 IP
  5. wasis

    wasis Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i'm using apache, pls help me for the script..!
     
    wasis, Sep 14, 2009 IP
  6. ohteddy

    ohteddy Member

    Messages:
    128
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #6
    <a href='yourfilename.pdf'>PDF</a>
     
    ohteddy, Sep 14, 2009 IP
  7. gclass

    gclass Active Member

    Messages:
    337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #7
    you can send me the web page file(html or php) and I will do it for you if you want.
     
    gclass, Sep 15, 2009 IP
  8. wasis

    wasis Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <INPUT id="btnopen" type="button" value="open report" name="Button1" onclick="location.href='pdf-php-tutorial-06.pdf'">
    </body>
    </html>

    this one is the another one:

    <html>
    <head>
    <script type="text/javascript">
    function showHideElement(element){
    var elem = document.getElementById(element);

    if (elem.style.display=="none"){
    elem.style.display="block"
    }
    else{
    elem.style.display="none"
    }
    }
    </script>
    </head>
    <body>
    <div style="position:absolute;height:100px;width:100px;background-color:Yellow;" onclick="showHideElement('Iframe1');">click me</div>
    <div style="position:absolute;z-index:100;background-color:Green;height:100px;width:100px;margin-left:200px;"></div>

    <div style="position:absolute;z-index:20;margin-left:200px;">
    <iframe visible="true" id="Iframe1" height="100" width="100" runat="server" frameborder="0" scrolling="auto" >

    </iframe>
    </div>

    <div style="position:absolute;z-index:10;margin-left:100px;">
    <iframe visible="true" id="ipdf" src="pdf-php-tutorial-06.pdf" height="1000" width="1000" runat="server" frameborder="0" scrolling="auto" >

    </iframe>
    </div>

    </body>
    </html>

    can you fix it?
     
    wasis, Sep 15, 2009 IP
  9. gclass

    gclass Active Member

    Messages:
    337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #9
    Hi

    both codes works fine here, are you sure you put the PDF file in the same directory as the HTML file?
    are you using apache server on your PC or real internet server?
    can you point me to your site? (you can send me a private message if you like)

    anyway, I have these two options: (I didnt understand what you tried to do in the second code so I made it simpler)

    option 1:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <INPUT id="btnopen" type="button" value="open report" name="Button1" onclick="location.href='pdf-php-tutorial-06.pdf'">
    </body>
    </html>


    option 2:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <embed src="pdf-php-tutorial-06.pdf#toolbar=1&navpanes=0&scrollbar=1" width="1000" height="1000"> </body>
    </html>
     
    gclass, Sep 17, 2009 IP