Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Open PDF-File in browser without href or embed

 
Thread Tools Search this Thread
Old 02-24-2004, 05:01 PM   #1
Default Open PDF-File in browser without href or embed


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
  Reply With Quote
Old 02-24-2004, 05:40 PM   #2
Kris
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

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/>
  Reply With Quote
Old 02-24-2004, 05:58 PM   #3
Warden Dave
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

"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


  Reply With Quote
Old 02-24-2004, 06:21 PM   #4
Kris
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

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/>
  Reply With Quote
Old 02-24-2004, 06:45 PM   #5
Hendrik Lampert
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

"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


  Reply With Quote
Old 02-24-2004, 06:53 PM   #6
Warden Dave
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed


"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


  Reply With Quote
Old 02-24-2004, 08:48 PM   #7
Toby A Inkster
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

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

  Reply With Quote
Old 02-24-2004, 09:22 PM   #8
Warden Dave
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

"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


  Reply With Quote
Old 02-25-2004, 07:48 AM   #9
Toby A Inkster
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

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

  Reply With Quote
Old 02-25-2004, 09:54 AM   #10
Warden Dave
 
Posts: n/a
Default Re: Open PDF-File in browser without href or embed

"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


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump