![]() |
|
|
|||||||
![]() |
HTML - Open PDF-File in browser without href or embed |
|
|
Thread Tools | Search this Thread |
|
|
#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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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/> |
|
|
|
#3 |
|
Posts: n/a
|
"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 |
|
|
|
#4 |
|
Posts: n/a
|
In article <c1g3er$1i688k$>,
"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/> |
|
|
|
#5 |
|
Posts: n/a
|
"Kris" <> schrieb im Newsbeitrag
news:kristiaan-... > 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 |
|
|
|
#6 |
|
Posts: n/a
|
"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 |
|
|
|
#7 |
|
Posts: n/a
|
Kris wrote:
> In article <c1g3er$1i688k$>, > "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 |
|
|
|
#8 |
|
Posts: n/a
|
"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 |
|
|
|
#9 |
|
Posts: n/a
|
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/scr...stlocation-src -- Toby A Inkster BSc (Hons) ARCS Contact Me - http://www.goddamn.co.uk/tobyink/?page=132 |
|
|
|
#10 |
|
Posts: n/a
|
"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 |
|