Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add combine function to [pdf] tag.
  • Loading branch information
racke committed Feb 18, 2011
1 parent ecde0c5 commit 6937c06
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions lib/Vend/PDF.pm
Expand Up @@ -32,15 +32,20 @@ use Vend::Data;
use Vend::Tags;

# define [pdf] tag
Vend::Config::parse_tag('UserTag', 'pdf Order specification template output');
Vend::Config::parse_tag('UserTag', 'pdf Order function specification template output');
Vend::Config::parse_tag('UserTag', 'pdf AddAttr');
Vend::Config::parse_tag('UserTag', 'pdf MapRoutine Vend::PDF::pdf');

# [pdf]
sub pdf {
my ($specification, $template, $output, $opt) = @_;
my (%input, $locale);
my ($function, $specification, $template, $output, $opt) = @_;
my (%input, $locale, $ret);

if ($function eq 'combine') {
$ret = combine($output, $opt->{files});
return;
}

# input for Zoom template
if (exists $opt->{input}) {
%input = %{$opt->{input}};
Expand Down Expand Up @@ -131,4 +136,21 @@ sub pdf {
return;
}

sub combine {
my ($output, $files) = @_;
my ($pdf, $import);

$pdf = new Template::Zoom::PDF (file => $output);

$import = new Template::Zoom::PDF::Import;

for my $pdf_file (@$files) {
$import->import(pdf => $pdf->{pdf}, file => $pdf_file);
}

$pdf->{pdf}->saveas();

return $output;
}

1;

0 comments on commit 6937c06

Please sign in to comment.