[Catalyst] generating and redirecting to pdfs
Moritz Onken
onken at houseofdesign.de
Wed Oct 21 11:16:18 GMT 2009
Am 21.10.2009 um 00:25 schrieb Steve Rippl:
> Hi,
>
> I'm using TT for my View templates, and I'm experimenting with
> Template::Plugin::Latex for generating pdf reports. Now I'm
> generating
> pdfs (which is nice!) but not redirecting to them at the end, so I
> suspect I'm using the wrong approach.
I'm doing the exact same thing, but without creating a temporary file:
my $template = "[% TT LATEX STUFF %]";
my $t = Template::Alloy->new;
my $out;
$t->process(\$template, {stash => 'bar'}, \$out) || die $@;
my $output = IO::String->new($out);
my $string = $output->string_ref;
$c->response->content_type('application/pdf');
$c->response->content_length( length $$string );
$c->res->body($$string);
You can probably skip the IO::String object...
That's about it.
cheers,
moritz
More information about the Catalyst
mailing list