Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Open PDF-File in browser without href or embed

Reply
Thread Tools

Open PDF-File in browser without href or embed

 
 
Hendrik Lampert
Guest
Posts: n/a
 
      02-24-2004
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


 
Reply With Quote
 
 
 
 
Kris
Guest
Posts: n/a
 
      02-24-2004
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
 
 
 
 
Warden Dave
Guest
Posts: n/a
 
      02-24-2004
"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
 
Kris
Guest
Posts: n/a
 
      02-24-2004
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
 
Hendrik Lampert
Guest
Posts: n/a
 
      02-24-2004
"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
 
Warden Dave
Guest
Posts: n/a
 
      02-24-2004

"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
 
Toby A Inkster
Guest
Posts: n/a
 
      02-24-2004
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
 
Warden Dave
Guest
Posts: n/a
 
      02-24-2004
"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
 
Toby A Inkster
Guest
Posts: n/a
 
      02-25-2004
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
 
Warden Dave
Guest
Posts: n/a
 
      02-25-2004
"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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASE HREF and A HREF="#" onclick="..." Vincent van Beveren Javascript 2 07-06-2006 08:33 AM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
onClick method question (this.href and document.location.href) yogesh.bhardwaj@gmail.com Javascript 2 02-03-2005 02:38 PM
difference between location.href and window.location.href? saiho.yuen Javascript 3 09-14-2004 06:51 PM
Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src Soren Vejrum Javascript 4 07-05-2003 01:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57