[Catalyst-commits] r11273 - in Catalyst-View-PDF-API2/trunk:
lib/Catalyst/View/PDF t/lib t/lib/TestApp/Controller
t/lib/TestApp/root/pdf_templates
ferz at dev.catalyst.perl.org
ferz at dev.catalyst.perl.org
Sat Aug 29 15:12:20 GMT 2009
Author: ferz
Date: 2009-08-29 15:12:16 +0000 (Sat, 29 Aug 2009)
New Revision: 11273
Modified:
Catalyst-View-PDF-API2/trunk/lib/Catalyst/View/PDF/API2.pm
Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/root/pdf_templates/test_pdf.tt
Log:
It start to work.
It fails only the testapp_server.pl with a render: plugin error - Catalyst::View::PDF::API2: plugin not found
Modified: Catalyst-View-PDF-API2/trunk/lib/Catalyst/View/PDF/API2.pm
===================================================================
--- Catalyst-View-PDF-API2/trunk/lib/Catalyst/View/PDF/API2.pm 2009-08-29 09:57:46 UTC (rev 11272)
+++ Catalyst-View-PDF-API2/trunk/lib/Catalyst/View/PDF/API2.pm 2009-08-29 15:12:16 UTC (rev 11273)
@@ -147,26 +147,31 @@
sub render_pdf {
my ($self, $c) = @_;
- $c->stash->{pdf} = PDF::API2->new;
- # [% USE pdf = Catalyst::View::PDF::API2 %]
+ #my $tempfile = tmpnam();
+ #$c->stash->{tempfile} = $tempfile;
+
my $template = <<'EOT';
+ [% USE Dumper %]
+ [% USE pdf2 = Catalyst::View::PDF::API2 %]
+ [% Catalyst.log.debug(Dumper.dump($pdf_template)) %]
[% PROCESS $pdf_template %]
EOT
- # my $tempfile = tmpnam();
- # $pdf = PDF::API2->open($tempfile);
- #
+ $c->stash->{pdf} = PDF::API2->new();
- #SEARCH: foreach my $path (@{$self->config->{INCLUDE_PATH}}) {
- # if (-e catfile($path,$c->stash->{pdf_template})) {
- # local $CWD = $path;
- # my $output = $self->render($c,\$template);
- # last SEARCH;
- # }
- #}
+ SEARCH: foreach my $path (@{$self->config->{INCLUDE_PATH}}) {
+ if (-e catfile($path,$c->stash->{pdf_template})) {
+ local $CWD = $path;
+ $DB::single=1;
+ my $output = $self->render($c,\$template);
+ $c->log->debug("render: $output");
+ last SEARCH;
+ }
+ $DB::single=1;
+ $c->log->debug("pdf_template non trovato");
+ }
my $pdfout = $c->stash->{pdf}->stringify;
- $c->stash->{pdf}->end;
return $pdfout;
}
Modified: Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm 2009-08-29 09:57:46 UTC (rev 11272)
+++ Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm 2009-08-29 15:12:16 UTC (rev 11273)
@@ -15,7 +15,7 @@
$c->stash( {
data => "This is a test page",
- pdf_template=>'test_pdf.tt2',
+ pdf_template=>'test_pdf.tt',
pdf_filename=>'test_pdf.pdf',
} );
Modified: Catalyst-View-PDF-API2/trunk/t/lib/TestApp/root/pdf_templates/test_pdf.tt
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/TestApp/root/pdf_templates/test_pdf.tt 2009-08-29 09:57:46 UTC (rev 11272)
+++ Catalyst-View-PDF-API2/trunk/t/lib/TestApp/root/pdf_templates/test_pdf.tt 2009-08-29 15:12:16 UTC (rev 11273)
@@ -1,4 +1,4 @@
- [% f1 = pdf->corefont('Helvetica', -encode=>'latin1') %]
+ [% f1 = pdf.corefont('Helvetica') %]
[% page = pdf.page %]
[% page.mediabox(421,595) %]
[% text = page.text %]
Modified: Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm 2009-08-29 09:57:46 UTC (rev 11272)
+++ Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm 2009-08-29 15:12:16 UTC (rev 11273)
@@ -6,9 +6,15 @@
$DB::single=1;
-__PACKAGE__->config('View::PDF' => {
- INCLUDE_PATH => __PACKAGE__->path_to('root','pdf_templates')
-});
+__PACKAGE__->config(
+ 'View::PDF::API2' =>
+ {
+ INCLUDE_PATH => __PACKAGE__->path_to('root','pdf_templates'),
+ COMPILE_EXT => 'c',
+ TEMPLATE_EXTENSION => '.tt',
+ CATALYST_VAR => 'Catalyst',
+ }
+);
More information about the Catalyst-commits
mailing list