Wally Hartshorn has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on a program that uses CGI::Application as its base. Just about everything is working except I am unable to display an Acrobat file to the user. I've read descriptions of how to do this and have followed them, but am having no luck getting it to actually work.
Here's some snippets of code:
sub view_file { my ($self) = @_; my $cgi = $self->query; my $cgi_vars = {$cgi->Vars}; my $order = EN::OrdersDB::OrdersUpdate->retrieve( $cgi_vars->{order_id} ); my $filename = $order->dlc_file_num . ".pdf"; my $file_blob = $order->pdf_files->pdf_file; my $file_size = length ($file_blob); $self->header_props( -type => "application/pdf", -attachment => $filename, -Content_Length => $file_size, -Content_Transfer_Encoding => "binary", ); return $file_blob; }
The resulting output looks something like this in the web browser:
Content-Disposition: attachment; filename="DLC12345.pdf" Content-lengt +h: 8741 Content-transfer-encoding: binary Content-Type: application/p +df %PDF-1.4 %âãÃÂà8 0 obj << /Linearized +1 /O 10 /H ( 694 170 ) /L 8741 /E 6007 /N 2 /T 8464 >> endobj xref 8 +14 0000000016 00000 n 0000000624 00000
... and so on. All of the expected stuff appears to be there, but it is displayed in the browser as if the Content-Type had not been changed to application/pdf.
Any suggestions?
Wally Hartshorn
(Plug: Visit JavaJunkies, PerlMonks for Java)
update (broquaint): added <code> tags to the output
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Displaying PDF files via CGI::Application
by bobn (Chaplain) on Sep 02, 2003 at 21:32 UTC | |
by weierophinney (Pilgrim) on Sep 03, 2003 at 02:40 UTC | |
|
Re: Displaying PDF files via CGI::Application
by Mr_Person (Hermit) on Sep 02, 2003 at 23:28 UTC | |
|
Re: Displaying PDF files via CGI::Application
by cLive ;-) (Prior) on Sep 03, 2003 at 10:30 UTC | |
|
Re: Displaying PDF files via CGI::Application
by Anonymous Monk on Sep 03, 2003 at 00:06 UTC | |
|
Re: Displaying PDF files via CGI::Application
by Wally Hartshorn (Hermit) on Sep 03, 2003 at 13:50 UTC |