Prince99 has asked for the wisdom of the Perl Monks concerning the following question:
I also tried a simple method of:$format = &Check_Format($report); &Display_Report($format); sub Check_Format { my $report = $_[0]; my ($name,$format) = split(/\./,$report); return uc($format); } sub Display_Report { my $type = $_[0]; my ($offset,$bytes,$buffer,$contents,$print_pdf); if ($type eq 'XLS') { $print_xls = 'path/to/data/reports'; open(XLS, "$print_xls") || Write_Error($print_xls); $offset = 0; $contents = ''; binmode XLS; until(eof(XLS)) { $bytes += read(XLS,$buffer, 1048576, $offset); $offset += 1048576; $contents .= $buffer; } close XLS; print header(-type => 'application/vnd.ms-excel'); print $contents; } else { if ($type eq 'PDF') { $print_pdf = '/path/to/data/reports'; open(PDF, "$print_pdf") || Write_Error($print_pdf); $offset = 0; $contents = ''; binmode PDF; until(eof(PDF)) { $bytes += read(PDF,$buffer, 1048576, $offset); $offset += 1048576; $contents .= $buffer; } close PDF; print header(-type => 'application/pdf'); print $contents; }
Any help you could offer would be appreciated. Is there a better way to open/display report files.print `echo "Content-type: application/pdf"`; print `echo`; print `cat /path/to/data/reports/file.pdf`;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: displaying excel/pdf files in browser
by VSarkiss (Monsignor) on Feb 27, 2002 at 16:57 UTC | |
|
Keep The Document Extensions - Re: displaying excel/pdf files in browser
by metadoktor (Hermit) on Feb 27, 2002 at 17:06 UTC | |
by Prince99 (Scribe) on Feb 27, 2002 at 17:59 UTC | |
|
Re: displaying excel/pdf files in browser
by Prince99 (Scribe) on Feb 27, 2002 at 19:13 UTC | |
by IDStewart (Acolyte) on Feb 27, 2002 at 20:19 UTC | |
by gellyfish (Monsignor) on Feb 27, 2002 at 21:10 UTC | |
|
Re: displaying excel/pdf files in browser
by cwsaylor (Acolyte) on Feb 28, 2002 at 15:01 UTC | |
by Heffstar (Acolyte) on Jul 10, 2008 at 16:46 UTC |