Public/Set-VellumPdfFooter.ps1

function Set-VellumPdfFooter {
    <#
    .SYNOPSIS
        Sets a running footer band on a VellumPdf document.
    .DESCRIPTION
        Wraps Document.SetFooter(template, style, alignment). The footer band
        appears at the bottom of every page. The document flows through the
        pipeline for chaining.

        Template tokens:
          {page} - replaced with the current page number (e.g. 2)
          {pages} - replaced with the total page count (e.g. 9)

        Example template: 'Page {page} of {pages}'
    .PARAMETER Document
        The live VellumPdf document flowing through the pipeline. The same
        instance is returned after the footer is configured, enabling chaining.
    .PARAMETER Template
        The footer text template. Use {page} for the current page number and
        {pages} for the total page count (e.g. 'Page {page} of {pages}').
        Mandatory.
    .PARAMETER Font
        A base-14 font name for the footer text. When omitted the document
        default font is used.
    .PARAMETER FontSize
        Font size in points for the footer text, between 1 and 1000. When
        omitted the document default size is used.
    .PARAMETER Alignment
        Horizontal alignment of the footer text. Accepts Left, Center, Right,
        or Justify. Defaults to Center.
    .EXAMPLE
        $doc | Set-VellumPdfFooter -Template 'Page {page} of {pages}'
    .EXAMPLE
        $doc | Set-VellumPdfFooter -Template '{page} / {pages}' `
               -Font TimesRoman -FontSize 9 -Alignment Right
    .OUTPUTS
        VellumPdf.Layout.Document (the same instance, for chaining)
    #>

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '',
        Justification = 'Mutates an in-memory document object only; no external/system state change.')]
    [CmdletBinding()]
    [OutputType([VellumPdf.Layout.Document])]
    param(
        [Parameter(Mandatory, ValueFromPipeline)]
        [VellumPdf.Layout.Document]$Document,

        [Parameter(Mandatory)]
        [string]$Template,

        [ValidateSet('Courier', 'CourierBold', 'CourierBoldOblique', 'CourierOblique',
            'Helvetica', 'HelveticaBold', 'HelveticaBoldOblique', 'HelveticaOblique',
            'Symbol', 'TimesBold', 'TimesBoldItalic', 'TimesItalic', 'TimesRoman', 'ZapfDingbats')]
        [string]$Font,

        [ValidateRange(1, 1000)]
        [double]$FontSize,

        [ValidateSet('Left', 'Center', 'Right', 'Justify')]
        [string]$Alignment = 'Center'
    )

    process {
        Assert-VellumPdfDocumentOpen -Document $Document -CommandName 'Set-VellumPdfFooter'
        Write-VellumPdfEncodingWarning -Text $Template -CommandName 'Set-VellumPdfFooter'
        $wantsFont = [bool]$Font -or $PSBoundParameters.ContainsKey('FontSize')
        $style = if ($wantsFont) {
            $default = Resolve-VellumPdfDefault -Document $Document
            $effFont = if ($Font) { $Font } else { $default.Font }
            $effSize = if ($PSBoundParameters.ContainsKey('FontSize')) { $FontSize } else { $default.FontSize }
            New-VellumTextStyle -Font $effFont -FontSize $effSize
        } else {
            $null
        }

        $halign = [VellumPdf.Layout.Core.HorizontalAlignment]::$Alignment
        [void]$Document.SetFooter($Template, $style, $halign)
        $Document
    }
}