[Dancer-users] Generating PDF with Template-Plugin-Latex fails inside route handler
Mike Mandel
mandel at stud.fh-hannover.de
Fri Jan 7 01:06:22 CET 2011
Hello,
I want to generate a pdf with Template-Plugin-Latex where the user fills
out a html form and
the app sends back a pdf.
Outside the route handler create_pdf() works and the pdf is generated,
but inside the route handler create_pdf() fails:
latex error - pdflatex exited with errors:
-----
Minimal example:
#!/usr/bin/perl
use Dancer;
use Template::Latex;
sub create_pdf {
my $tt = Template::Latex->new({
INCLUDE_PATH =>
'/path/to/my/app/public/latex',
OUTPUT_PATH => '/path/to/my/app/public/pdf',
LATEX_FORMAT => 'pdf',
});
$tt->process('test.tt', {name => 'Dancer'}, 'test.pdf', binmode =>
1) || die $tt->error();
};
# works
create_pdf();
get '/' => sub {
return 'Hello Dancer';
};
get '/create_pdf' => sub {
# works not
create_pdf();
};
get '/download/:file' => sub {
send_file('/pdf/'.params->{file});
};
dance();
----
My template test.tt
[% USE Latex %]
[% FILTER latex('pdf') %]
\documentclass[version=last]{scrartcl}
\begin{document}
Hello [% name %]
\end{document}
[% END %]
Any suggestions what could be wrong?
Thanks a lot,
Mike
More information about the Dancer-users
mailing list