Problem using FPDF

Problem using FPDF

am 07.11.2007 13:22:07 von cappieins

Hi,

i've got a problem using PHP FPDF library to create PDF files send
inline to
a browser window.

The created PDF file opens correctly in the browser (IE 6), but if I
want to save
it to my local disk, there is not automatically the filename used I
passed
to the "Output" function of the lib.

Instead the name of the html page is proposed in the file chooser.

Does anyone have an idea how to get the correct filename automatically
in teh file chooser dialog?

Thanks in advance,
Carsten

Re: Problem using FPDF

am 07.11.2007 15:14:27 von Steve

wrote in message
news:1194438127.438736.243150@50g2000hsm.googlegroups.com...
> Hi,
>
> i've got a problem using PHP FPDF library to create PDF files send
> inline to
> a browser window.
>
> The created PDF file opens correctly in the browser (IE 6), but if I
> want to save
> it to my local disk, there is not automatically the filename used I
> passed
> to the "Output" function of the lib.
>
> Instead the name of the html page is proposed in the file chooser.
>
> Does anyone have an idea how to get the correct filename automatically
> in teh file chooser dialog?

what fpdf version are you using? whatever the case, just look a the output
function and check what headers it's sending out. check to make sure there
is header line for:

header('content-disposition: attachment; filename="' . $name . '"');

and that $name (or whatever variable name is used for the file name param)
is set...you also need to make sure you are passing 'D' as the $dest
(destination) param.

hth,

me

Re: Problem using FPDF

am 07.11.2007 16:03:40 von cappieins

Hi,

i'm using fpdf version 1.53, but passing an "I" for "inline" as
destination, because I want the browser to open the pdf directly using
the browser plugin. If I use "D", there appears a dialog asking me to
save or to open the file. But thst's not what I want to have...

The header is set corectly for "D" as you wrote, and for "I" it is

header('Content-disposition: attachment; filename="'.$name.'"');

Any further idea?

Thanks,
Carsten

Re: Problem using FPDF

am 07.11.2007 16:05:56 von cappieins

Hi,

i'm using fpdf version 1.53, but passing an "I" for "inline" as
destination, because I want the browser to open the pdf directly
using
the browser plugin. If I use "D", there appears a dialog asking me to
save or to open the file. But thst's not what I want to have...


The header is set corectly for "D" as you wrote, and for "I" it is


header('Content-disposition: inline; filename="'.$name.'"');


Any further idea?


Thanks,
Carsten

Re: Problem using FPDF

am 07.11.2007 17:39:52 von Steve

"Tompkins" wrote in message
news:1194447820.498426.198680@d55g2000hsg.googlegroups.com.. .
> Hi,
>
> i'm using fpdf version 1.53, but passing an "I" for "inline" as
> destination, because I want the browser to open the pdf directly using
> the browser plugin. If I use "D", there appears a dialog asking me to
> save or to open the file. But thst's not what I want to have...
>
> The header is set corectly for "D" as you wrote, and for "I" it is
>
> header('Content-disposition: attachment; filename="'.$name.'"');
>
> Any further idea?

well, for starters, don't switch thoughts mid-stream!

"but if I want to save it to my local disk, there is not automatically the
filename used I passed"

and then:

"because I want the browser to open the pdf directly using the browser
plugin."

stick with telling us EXACTLY what you are having problems with, and maybe
we can help you.

Re: Problem using FPDF

am 07.11.2007 17:48:30 von Steve

"Steve" wrote in message
news:XSlYi.25$rk.2@newsfe05.lga...
>
> "Tompkins" wrote in message
> news:1194447820.498426.198680@d55g2000hsg.googlegroups.com.. .

ok, i re-read your hodge-podge op. what you're saying is that:

=====

i want to display a pdf directly in the browser, and when i use the
*browser's* file->"save as" menu option, the browser gives the default file
name as the name of the url/web-page rather than the file name i specified
in the header.

=====

if that is the case, there is nothing you can do to be consistent across all
browsers. headers are "directives", not "commands". the browser treats them
like *suggestions* and nothing more. this has nothing to do with fpdf.

to test it, put an already created pdf in your web root, use a browser to
pull it up via its url...then file->'save as'. notice, url...not file name.

Re: Problem using FPDF

am 07.11.2007 19:25:14 von cappieins

The test case you describe is exactly what I did, and it works properly.

I tested it with a PDF document that was created using fpdf, so I don't
understand wht's the reason for this behavior.

Thanks,
Carsten

Re: Problem using FPDF

am 07.11.2007 22:42:38 von Steve

"Carsten Wesch" wrote in message
news:fgsvug$9k2$03$1@news.t-online.com...
> The test case you describe is exactly what I did, and it works properly.
>
> I tested it with a PDF document that was created using fpdf, so I don't
> understand wht's the reason for this behavior.

well then, you've got me stumped. i had different test results. have you
echo'ed out $name and then exited immediately so you could see the value of
$name?

Re: Problem using FPDF

am 07.11.2007 22:46:45 von Steve

"Carsten Wesch" wrote in message
news:fgsvug$9k2$03$1@news.t-online.com...
> The test case you describe is exactly what I did, and it works properly.
>
> I tested it with a PDF document that was created using fpdf, so I don't
> understand wht's the reason for this behavior.

actually, i didn't describe fully what the test should be. your uri to the
document *IS* some.file.pdf...so your browser will want to save it as the
same. if, however, you made a script called some.file.php, and in it put:

header('content-disposition: attachment; filename=some.file.pdf');
echo file_get_contents('some.file.pdf');
?>

your browser would STILL want to save it as some.file.php...which is the uri
resource name. see the difference?