Chady has asked for the wisdom of the Perl Monks concerning the following question:

fellow monks,

I have the following script that gathers some stuff from a MySQL database and generates a PDF File, and it's all done through CGI.

problem is, the client wants it to open inline whenever possible, so here's my header:
use CGI qw/header/; print header(-type => 'application/pdf', -content_disposition => 'inline' );
I'm using PDF::Create, and here's the start code:
use PDF::Create; my $pdf = new PDF::Create( #'filename' => 'test.pdf', 'fh' => *STDOUT, 'Version' => 1.2, 'PageMode' => 'UserOutlines', 'Author' => 'test', 'Title' => 'Invoice...' );
if I output to a file, it's correct, but when I output to STDOUT and use the browser, I have to press Refresh everytime so that acrobat shows the page.

is this just a browser hickup? (trying on IE6 btw) or should something be done to the output? the same script is used for other requests, and every time the result is diffrent one time it works and one time it's doesn't, but I can't figure out why..

Thanx in advance.
He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/

Replies are listed 'Best First'.
Re: Inline PDF not showing.
by blm (Hermit) on Sep 23, 2002 at 15:06 UTC

    I don't suppose you could post more of the perl script?

    You say that it could be a browser issue. Can you try other browsers?

    I spent an hour doing a server push version of what I think is your script but then found that IE doesn't support server push only client pull. :-( I can post the code if anyone wants!

    --blm--
Re: Inline PDF not showing.
by RMGir (Prior) on Sep 23, 2002 at 13:14 UTC
    I'm not an IE (or CGI) expert, so these are just guesses, but I'm hoping one of them helps.

    If your user has IE set up to open PDF files without asking, could you just issue a redirect header to the PDF file?

    And what happens if you don't specify disposition?
    --
    Mike

Re: Inline PDF not showing.
by guha (Priest) on Sep 23, 2002 at 22:00 UTC

    Glad you asked, been doing some research with MrCromeDome and inlined tif's and had some problems.

    However with pdf thing work correctly :-],
    see working example below

    my $in_file = "c:/some/path/chady.pdf"; $|++; undef $/; open(IN, $in_file) || die "No open"; binmode(IN); my $buffer = <IN>; close(IN); my $in_file_len = -s $in_file; binmode(STDOUT); print <<EOF; HTTP/1.0 200 OK Content-Type: application/pdf; name="chady.pdf" Content-Transfer-Encoding: binary Content-Disposition: inline; filename="chady.pdf" Content-Length: $in_file_len EOF print $buffer;
    HTH