Open PDF-File in browser without href or embed

Discussion in 'HTML' started by Hendrik Lampert, Feb 24, 2004.

  1. Hi,

    a simple html page consists of a select box (1,2,3,4,5....). After selectin
    one of the numbers, the corresponding PDF File should appear in the browser.
    Doing it with "<embed src=... width=... height=...> fixes the size of the
    PDF frame. Is there any way to get a dynamic output size, like calling the
    PDF via href?
    Any other solution?

    Many thanks.
    Regards,
    Hendrik
    Hendrik Lampert, Feb 24, 2004
    #1
    1. Advertising

  2. Hendrik Lampert

    Kris Guest

    In article <c1g01h$r5q$>,
    "Hendrik Lampert" <> wrote:

    > a simple html page consists of a select box (1,2,3,4,5....). After selectin
    > one of the numbers, the corresponding PDF File should appear in the browser.
    > Doing it with "<embed src=... width=... height=...> fixes the size of the
    > PDF frame. Is there any way to get a dynamic output size, like calling the
    > PDF via href?


    Here a piece of PHP:


    <?php
    // when form submitted, redirect to PDF file
    if($file=="dick.pdf" || $file=="andrea.pdf" || $file=="lewis.pdf")
    {
    header("Location: $file");
    exit();
    }

    // and else just display the thing
    ?>
    <html>
    <head>

    <title>Download a PDF file</title>

    </head>
    <body>

    <form action="thisfile.php" method="get">
    <fieldset>
    <legend>Please select a PDF file to download</legend>

    <select name="file" size="1">
    <option value="dick.pdf">Dick</option>
    <option value="andrea.pdf">Andrea</option>
    <option value="lewis.pdf">Lewis</option>
    </select>
    <input type="submit" value="Download!">

    </form>

    </body>
    </html>

    --
    Kris
    <> (nl)
    <http://www.cinnamon.nl/>
    Kris, Feb 24, 2004
    #2
    1. Advertising

  3. Hendrik Lampert

    Warden Dave Guest

    "Kris" <> wrote:

    > <?php
    > // when form submitted, redirect to PDF file
    > if($file=="dick.pdf" || $file=="andrea.pdf" || $file=="lewis.pdf")
    > {
    > header("Location: $file");
    > exit();
    > }

    <snip>

    Please notice http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html ,
    14.30 Location : [....] The field value consists of a single absolute URI

    Location = "Location" ":" absoluteURI


    WD
    Warden Dave, Feb 24, 2004
    #3
  4. Hendrik Lampert

    Kris Guest

    In article <c1g3er$1i688k$-berlin.de>,
    "Warden Dave" <> wrote:

    > Please notice http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html ,
    > 14.30 Location : [....] The field value consists of a single absolute URI
    >
    > Location = "Location" ":" absoluteURI


    You are right. Damn, I have been doing it wrongly for so long now then.
    Is the Content-location header a good solution then, to redirect through
    a relative URI?

    I have RFC2616 lying beside the bed, never got to it reading the thing.
    :)

    --
    Kris
    <> (nl)
    <http://www.cinnamon.nl/>
    Kris, Feb 24, 2004
    #4
  5. "Kris" <> schrieb im Newsbeitrag
    news:4all.nl...
    > In article <c1g01h$r5q$>,
    > "Hendrik Lampert" <> wrote:
    >
    > > a simple html page consists of a select box (1,2,3,4,5....). After

    selectin
    > > one of the numbers, the corresponding PDF File should appear in the

    browser.
    > > Doing it with "<embed src=... width=... height=...> fixes the size of

    the
    > > PDF frame. Is there any way to get a dynamic output size, like calling

    the
    > > PDF via href?

    >
    > Here a piece of PHP:
    >
    >
    > <?php
    > // when form submitted, redirect to PDF file
    > if($file=="dick.pdf" || $file=="andrea.pdf" || $file=="lewis.pdf")
    > {
    > header("Location: $file");
    > exit();
    > }
    >
    > // and else just display the thing
    > ?>
    > <html>
    > <head>
    >
    > <title>Download a PDF file</title>
    >
    > </head>
    > <body>
    >
    > <form action="thisfile.php" method="get">
    > <fieldset>
    > <legend>Please select a PDF file to download</legend>
    >
    > <select name="file" size="1">
    > <option value="dick.pdf">Dick</option>
    > <option value="andrea.pdf">Andrea</option>
    > <option value="lewis.pdf">Lewis</option>
    > </select>
    > <input type="submit" value="Download!">
    >
    > </form>
    >
    > </body>
    > </html>
    >
    > --
    > Kris
    > <> (nl)
    > <http://www.cinnamon.nl/>


    The mistake i made was, to embed the pdf into a html table. If you do so,
    the percantage parameters for height and width in <embed ....> won't work.
    Outside ab table everything works fine.

    Hendrik
    Hendrik Lampert, Feb 24, 2004
    #5
  6. Hendrik Lampert

    Warden Dave Guest

    "Kris" <> wrote:
    > "Warden Dave" <> wrote:


    > > Please notice http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html ,
    > > 14.30 Location : [....] The field value consists of a single absolute URI
    > >
    > > Location = "Location" ":" absoluteURI

    >
    > You are right. Damn, I have been doing it wrongly for so long now then.
    > Is the Content-location header a good solution then, to redirect through
    > a relative URI?
    >
    > I have RFC2616 lying beside the bed, never got to it reading the thing.
    > :)


    If you want to indicate the URI of a variant relative to the
    Request-URI: yes.

    (To state the obvious: You can use "Location" and simply build
    the absoluteURI; +/-:

    "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]) . "/$file";

    )


    WD
    Warden Dave, Feb 24, 2004
    #6
  7. Kris wrote:

    > In article <c1g3er$1i688k$-berlin.de>,
    > "Warden Dave" <> wrote:
    >
    >> Please notice http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html ,
    >> 14.30 Location : [....] The field value consists of a single absolute URI
    >>
    >> Location = "Location" ":" absoluteURI

    >
    > You are right. Damn, I have been doing it wrongly for so long now then.


    Nah, Kris... don't worry - you're alright. PHP intercepts the header and
    replaces it with one that makes more sense.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
    Toby A Inkster, Feb 24, 2004
    #7
  8. Hendrik Lampert

    Warden Dave Guest

    "Toby A Inkster" <> wrote:
    > Kris wrote:


    > >> Please notice http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html ,
    > >> 14.30 Location : [....] The field value consists of a single absolute URI
    > >>
    > >> Location = "Location" ":" absoluteURI

    > >
    > > You are right. Damn, I have been doing it wrongly for so long now then.


    > Nah, Kris... don't worry - you're alright. PHP intercepts the header and
    > replaces it with one that makes more sense.


    Don't count on it. A 'note' can be found here:
    http://www.php.net/manual/en/function.header.php
    ["Note: HTTP/1.1 requires an absolute URI as argument to Location: including
    " the scheme, hostname and absolute path, but some clients accept relative
    URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and
    dirname() to make an absolute URI from a relative one yourself"]

    On my Apache server (2.0.40) with PHP (4.3.4) nothing of the sort happens.


    WD
    Warden Dave, Feb 24, 2004
    #8
  9. Warden Dave wrote:

    > "Toby A Inkster" <> wrote:
    >> Kris wrote:

    >
    >> >> Please notice http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html ,
    >> >> 14.30 Location : [....] The field value consists of a single absolute URI
    >> >>
    >> >> Location = "Location" ":" absoluteURI
    >> >
    >> > You are right. Damn, I have been doing it wrongly for so long now then.

    >
    >> Nah, Kris... don't worry - you're alright. PHP intercepts the header and
    >> replaces it with one that makes more sense.

    >
    > On my Apache server (2.0.40) with PHP (4.3.4) nothing of the sort happens.


    Well, over here, it seems to be intercepted and replaced with the
    Content-Location header (which does accept relative URIs).

    Example:
    http://www.goddamn.co.uk/tobyink/scratch/testlocation
    http://www.goddamn.co.uk/tobyink/scratch/testlocation-src

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
    Toby A Inkster, Feb 25, 2004
    #9
  10. Hendrik Lampert

    Warden Dave Guest

    "Toby A Inkster" <> wrote:
    > Warden Dave wrote:


    >>> Nah, Kris... don't worry - you're alright. PHP intercepts the header and
    >>> replaces it with one that makes more sense.


    >> On my Apache server (2.0.40) with PHP (4.3.4) nothing of the sort happens.


    > Well, over here, it seems to be intercepted and replaced with the
    > Content-Location header (which does accept relative URIs).

    <snip>
    > http://www.goddamn.co.uk/tobyink/scratch/testlocation


    It's very nice if 'somewhere' down the line 'something' is trying to correct
    your mistakes, I guess. The Content-Location header is there, but after the
    "replacement" I still see: "Location: tables".


    WD
    Warden Dave, Feb 25, 2004
    #10
  11. Hendrik Lampert

    rickyric

    Joined:
    Nov 17, 2010
    Messages:
    1
    Your code helped... Many thanks.
    rickyric, Nov 17, 2010
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CRON
    Replies:
    24
    Views:
    200,255
    Adrienne Boswell
    Jun 20, 2006
  2. salonowiec

    Open file without <a href

    salonowiec, Aug 29, 2007, in forum: HTML
    Replies:
    3
    Views:
    1,035
  3. Ricardo Pog
    Replies:
    1
    Views:
    375
    Austin Ziegler
    Mar 26, 2008
  4. Soren Vejrum
    Replies:
    4
    Views:
    496
    Lasse Reichstein Nielsen
    Jul 5, 2003
  5. saiho.yuen
    Replies:
    3
    Views:
    392
    kaeli
    Sep 14, 2004
Loading...

Share This Page