NAME
PDF::Make::Builder::Page::Header - Repeating page header for PDF::Make
SYNOPSIS
use PDF::Make::Builder;
my $builder = PDF::Make::Builder->new(
header => {
h => 30,
show_page_num => 'right',
page_num_text => 'Page {num}',
},
);
DESCRIPTION
Defines a header region rendered at the top of every page. Supports automatic page numbering and an optional custom render callback.
PROPERTIES
- h (Num, default 30)
-
Height of the header region in points.
- padding (Num, default 20)
-
Horizontal padding inside the header.
- show_page_num (Str)
-
Where to show the page number:
'left','center', or'right'. Omit to hide. - page_num_text (Str, default
'Page {num}') -
Template string for the page number.
{num}is replaced with the current page number. - cb (CodeRef)
-
Custom render callback invoked as
$cb->($self, $builder, ctx => $ctx, canvas => $canvas, y => $y, w => $w, h => $h);$ctxis a PDF::Make::Builder::Page::HeaderFooterContext providing region-aware helpers (text,page_num,line,box,image,note,link) and region accessors (left,right,top,bottom,center_x,center_y,inset). The rawcanvas,y,w,hargs are retained for backward compatibility.
EXAMPLE
$builder->add_page_header(
h => 40,
cb => sub {
my ($self, $builder, %args) = @_;
my $ctx = $args{ctx};
$ctx->text(text => 'My Document', align => 'left',
font => { size => 10, bold => 1 });
$ctx->page_num(format => 'Page {num} of {total}', align => 'right');
$ctx->line(y1 => $ctx->bottom + 2, y2 => $ctx->bottom + 2,
colour => '#999');
},
);