Open PDF-File in browser without href or embed

H

Hendrik Lampert

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
 
K

Kris

Hendrik Lampert said:
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>
 
K

Kris

Warden Dave said:
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.
:)
 
H

Hendrik Lampert

Kris said:
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>

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
 
W

Warden Dave

Kris said:
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
 
W

Warden Dave

Toby A Inkster said:
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
 
T

Toby A Inkster

Warden said:
Toby A Inkster said:
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
 
W

Warden Dave

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top