[Catalyst] How create a PDF report?
ryan lauterbach
ryan at radianit.com
Fri Jun 9 20:19:45 CEST 2006
catalyst-bounces at lists.rawmode.org wrote on 06/09/2006 05:37:04 AM:
>>>> Hi, I'm been using Catalyst recently to make a little application and
>>>> I want to create a PDF report, I have it using TT, Is there a way to
>>>> make it in PDF format?. I was reading the documentation but I didn't
>>>> found (or maybe didn't see ) something about that, I also search in
>>>> CPAN but I didn't see some module or plugin for this. How can I do
>>>> this? Is there a module or documentation about this?.
>>>>
>>>>
I did something similar a while back, I didn't know about Latex or any
other PDF generation method. Just used htmldoc to process the the html
output from TT:
... in your controller
# generate the html body
$c->forward( $c->view('TT') );
# write to tmp file as I couldn't get my version of htmldoc to work
correctly from STDIN
my $tmp = "/tmp/pdf_tmp.$$.html";
open F, ">$tmp" or die "Can't write: $!";
print F $c->res->body;
close F;
$c->res->header('Content-Type' => 'application/pdf');
$c->res->header('Content-Disposition' => qq[inline;
filename="$filename"]);
open PDF, '-|', (qw</usr/bin/htmldoc --quiet>, @args, qw<
--charset iso-8859-1 --footer .1. --size a4 --format pdf14
--portrait --size a4 --format pdf14 --portrait --webpage>, $tmp)
or die "Open: $!";
local $/;
my $out = <PDF>;
close PDF;
$c->res->body($out);
unlink $tmp;
-------------------
or something to that effect
More information about the Catalyst
mailing list