[% USE Latex %] [% FILTER latex('example.pdf') %] \documentclass[letterpaper,10pt]{article} \usepackage{marvosym} . . . \end{document} [% END %] #### [pdf] include_path='/etc/ymd/client_name/tmpl/' template='weekly_report_pdf.tt' output_path='/home/reports/pdfs/' report_type='weekly/' output='wkly_rpt__' suffix='_w' #### package My::Module; use warnings; use strict; use File::Path; use Template::Latex; use Template::Constants qw( :debug ); use Template::Filters; use base 'CGI::FormBuilder::Config::Simple'; sub new { my $class = shift; my $ini = shift; # creates a Config::Simple object; # creates a DBI::db object return $self; } sub render_pdf_report { my $self = shift; my $field = shift; my $template = $self->{'cfg'}->param("pdf.template"); $self->{'pdf_output_path'} = $self->{'cfg'}->param("pdf.output_path") . $field->{'region'} . '/' . $self->{'cfg'}->param("pdf.report_type"); $self->{'pdf_output_path'} =~ s/\ /_/g; chomp($self->{'pdf_output_path'}); unless( -d $self->{'pdf_output_path'} ){ mkpath $self->{'pdf_output_path'}; } $self->{'pdf_output'} = 'wkly_rpt_' . $field->{'region'} . '_' . $field->{'report_id'} . $self->{'cfg'}->param("pdf.suffix") . '.pdf'; $self->{'pdf_output'} =~ s/\ /_/g; chomp($self->{'pdf_output'}); $field->{'pdf_output'} = $self->{'pdf_output'}; $self->{'latex_paths'} = Template::Latex->latex_paths(); $self->{'tt'} = Template::Latex->new({ DEBUG => DEBUG_FILTERS | DEBUG_PLUGINS, INCLUDE_PATH => $self->{'cfg'}->param("pdf.include_path"), OUTPUT_PATH => $self->{'pdf_output_path'}, LATEX_FORMAT => 'pdf' }); $Template::Latex::DEBUG = 1; $self->{'tt'}->process($template,{ field => $field },$self->{'pdf_output'},binmode => 1) || die $self->{'tt'}->error(); my $tmp_file = $self->{'pdf_output_path'} . 'example.pdf'; my $file = $self->{'pdf_output_path'} . $self->{'pdf_output'}; rename $tmp_file, $file; return; } #### [Template::Filters] store(latex_encode, ARRAY(0x9157390)) [Template::Filters] store(latex, ARRAY(0x91573c0)) [Template::Plugins] fetch(Latex, , Template::Context=HASH(0x91036c0)) [Template::Plugins] loading Template::Plugin::Latex.pm (PLUGIN_NAME) [Template::Plugins] calling Template::Plugin::Latex->load() [Template::Plugins] Latex => Template::Plugin::Latex [Template::Filters] store(latex_encode, ARRAY(0x92022c8)) [Template::Filters] store(latex, ARRAY(0x9202288)) [Template::Filters] fetch(latex, [ example.pdf ], Template::Context=HASH(0x91036c0)) #### ok 6 - We have correct path to: ps2pdf ok 7 - We have correct path to: dvips ok 8 - We have correct path to: bibtex ok 9 - We have correct path to: pdflatex ok 10 - We have correct path to: makeindex ok 11 - We have correct path to: latex ok 12 - Generated correct file name ok 13 - Generated the correct file path ok 14 - The file exists not ok 15 - Our file is a pdf file # TODO Not yet successfully producing our pdf files # Failed (TODO) test 'Our file is a pdf file' # at t/11-pdf-report.t line 64. # 'text/plain' # doesn't match '(?-xism:application/pdf)' not ok 16 - We replicated a correct pdf file. # TODO Not yet successfully producing our pdf files # Failed (TODO) test 'We replicated a correct pdf file.' # at t/11-pdf-report.t line 66. # got: 'e1c06d85ae7b8b032bef47e42e4c08f9' # expected: 'c27f1cab0f2e44184ebd8ce5361db134'