NAME

PDF::Make::Builder::Page::HeaderFooterContext - Region-aware helpers for header/footer render callbacks

SYNOPSIS

$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');
    },
);

DESCRIPTION

Passed as the ctx keyword to header/footer cb callbacks. Provides region-scoped helpers for drawing text, shapes, images, and annotations into a header or footer without recomputing coordinates or re-implementing canvas primitives.

REGION ACCESSORS

left, right, bottom, top

Edge coordinates of the region.

center_x, center_y

Center of the region.

baseline($offset)

Returns y0 + $offset.

inset($dx, $dy)

Returns ($x, $y, $w, $h) of the region inset by $dx / $dy.

HELPERS

text(text => ..., align => ..., x => ..., y => ..., font => {...})

Draw a single line of text. align is left, center, or right within the region. x/y override alignment and default baseline.

page_num(format => 'Page {num}', align => 'right', font => {...})

Draw a page number. {num} and {total} are substituted. Defaults: size 8, colour #666, align right.

line(from => [x,y], to => [x,y], type => 'solid'|'dashed'|'dots', ...)

Draw a straight line. Alternatively pass x1/y1/x2/y2.

box(x => ..., y => ..., w => ..., h => ..., fill_colour => ...)

Draw a filled or stroked rectangle. fill_colour => 'transparent' produces a stroked outline.

image(src => ..., align => ..., w => ..., h => ...)

Embed an image. Aspect ratio is preserved when only one dimension is given. Defaults to the region height when neither is set.

note(rect => [x0,y0,x1,y1], text => ..., icon => ...)

Add a PDF text annotation, attached to the current page.

link(rect => [...], url|page|action|file => ...)

Add a link annotation, attached to the current page.

SEE ALSO

PDF::Make::Builder::Page::Header, PDF::Make::Builder::Page::Footer