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 }