I'm working on a little application which requires the generation of PDF files. Overseeing the whole app is CGI::Application. I was rather perplexed as to how to set header-type to something other than 'text/html'. It turns out that the answer is not $self->header_type('application/pdf'). You will get an "invalid header_type 'application/pdf'" error. The answer, courtesy of weierophinney is
$self->header_type('header');Kind of unintuitive, but I can guarantee that it works.
$self->header_props(-type=>'application/pdf');
More info from Adam Gent also shows how to name the downloaded file:
Through the header_props method is C::A, which goes via CGI.pmPosted by torque at October 3, 2004 5:27 PM | TrackBack$webapp->header_props(-type=>'image/gif',-expires=>'+3d');
So you can then do
$webapp->header_props(-type => "text/comma-separated-values",
-attachment => "download.csv");Should work fine.
You can also do this for zip and pdf files, if you set the correct header type, i.e., application/zip, application/pdf
What package/module are you using that actually creates the PDF file?
Posted by: Name at February 11, 2005 11:43 AMGood job!
Posted by: Markus at December 11, 2006 10:49 AMPop trio Atomic Kitten will reform to play a concert in support of jailed Liverpool football fan Michael Shields...
Posted by: Wyatt Osullivan at December 12, 2006 5:57 AMGood job!
Posted by: Markus at December 12, 2006 7:43 PM