in reply to Displaying PDF files via CGI::Application

You are seeing the headers in your browser window, indicating that some process has already sent a set of headers to your browser before the headers you are intendinign to be the headers (including the application/pdf header).

If you have lynx handy (say on a Linux or *BSD box - there may be a PC version - try:

lynx -head -dump your_URL_here
to see what the headers are.

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.

Replies are listed 'Best First'.
Re: Re: Displaying PDF files via CGI::Application
by weierophinney (Pilgrim) on Sep 03, 2003 at 02:40 UTC
    You are seeing the headers in your browser window, indicating that some process has already sent a set of headers to your browser before the headers you are intending

    Absolutely correct. CGI::Application has a special method for defining headers; if you don't follow it, it will send 'text/html' as the doctype.

    To override the headers, the OP used the appropriate construct:

    • $self->header_props(-type=>'application/pdf'...);
    The only thing I would add is that the CGI::Application POD says that header_props should be used in conjunction with header_type:
    • $self->header_type('header');
    might do the trick; however, that's the default value.

    My only other suggestion to the OP is to look and see if another print statement might be happening somewhere earlier in the process -- try running the application from the command line and look at the output for any whitespace preceding the headers.