No. That can't work. That's also not what I showed. You will need to supply that parameter yourself, outside of the "parameters". A subroutine reference never takes parameters. Maybe something like the following:
my $pdf = PDF::API2::Simple->new( header => \&my_header($CategoryName), footer => \&footer, margin_left => 15, margin_top => 15, margin_right => 15, margin_bottom => 45 ); sub my_header { my $pdf = shift; my $cat = $CategoryName; print $cat; header($pdf); } sub header { my $pdf = shift; # do my stuff }
... or, alternatively, if your $CategoryName changes several times before your (different) PDF objects output themselves, you can create the subroutines anonymously on the fly:
my $pdf = PDF::API2::Simple->new( header => sub { my_header($CategoryName), }, footer => \&footer, margin_left => 15, margin_top => 15, margin_right => 15, margin_bottom => 45 ); sub header { my $pdf = shift; # do my stuff }
In reply to Re^5: PDF::API2::Simple - pass parameter to header
by Corion
in thread PDF::API2::Simple - pass parameter to header
by constantin.iliescu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |