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 }