API Reference

Cmdlet

Set-OfficePdfHeader

Aliases: PdfHeader
Namespace PSWriteOffice
Aliases
PdfHeader
Inputs
OfficeIMO.Pdf.PdfDocument
Outputs
OfficeIMO.Pdf.PdfDocument

Sets a simple or fully composed running PDF header.

Remarks

Sets a simple or fully composed running PDF header.

Examples

Authored help example

Example 1: Add a running report header.

PS>


New-OfficePdf -Path .\Examples\Documents\PdfHeader.pdf {
                Set-OfficePdfHeader -Text 'Service Review' -Align Right -FontSize 9
                Add-OfficePdfHeading -Text 'Service Review'
                Add-OfficePdfParagraph -Text 'The header repeats on generated pages.'
            }
        

Sets header text for the generated PDF.

Example 2: Compose styled default, first-page, and even-page headers.

PS>


New-OfficePdf -Path .\Examples\Documents\RichHeader.pdf {
                Set-OfficePdfHeader -Compose {
                    param($header)
                    $label = New-OfficeTextRun -Text 'Service report ' -Bold | ConvertTo-OfficePdfTextRun
                    $pageStyle = New-OfficeTextRun -Italic | ConvertTo-OfficePdfTextRun
                    $null = $header.Text({
                        param($text)
                        $null = $text.Run($label).CurrentPage($pageStyle)
                    })
                    $null = $header.FirstPageText('Service report cover')
                    $null = $header.EvenPagesZones('Service report', $null, 'Page {page}/{pages}')
                }
                Add-OfficePdfParagraph -Text 'Generated report body.'
            }
        

The native composer owns rich runs, page tokens, zones, images, shapes, and page variants.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.

Syntax

Set-OfficePdfHeader [-Align <Left|Center|Right|Justify>] [-Compose <ScriptBlock>] [-FontSize <Nullable`1>] [-PassThru] [-Text <String>] [<CommonParameters>]
#
Parameter set: Context

Parameters

Align PdfAlign optionalposition: namedpipeline: Falsevalues: 4
Header alignment. Possible values: Left, Center, Right, Justify
Possible values: Left, Center, Right, Justify
Compose ScriptBlock optionalposition: namedpipeline: False
Advanced header composer. The script receives a PdfHeaderCompose and can configure default, first-page, and even-page text, zones, images, shapes, rich text, and page tokens.
FontSize Nullable`1 optionalposition: namedpipeline: False
Header font size in PDF points.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated document.
Text String optionalposition: 0pipeline: False
Header text. Supports {page} and {pages}.

Outputs

OfficeIMO.Pdf.PdfDocument

Set-OfficePdfHeader [-Align <Left|Center|Right|Justify>] [-Compose <ScriptBlock>] -Document <PdfDocument> [-FontSize <Nullable`1>] [-PassThru] [-Text <String>] [<CommonParameters>]
#
Parameter set: Document

Parameters

Align PdfAlign optionalposition: namedpipeline: Falsevalues: 4
Header alignment. Possible values: Left, Center, Right, Justify
Possible values: Left, Center, Right, Justify
Compose ScriptBlock optionalposition: namedpipeline: False
Advanced header composer. The script receives a PdfHeaderCompose and can configure default, first-page, and even-page text, zones, images, shapes, rich text, and page tokens.
Document PdfDocument requiredposition: namedpipeline: True (ByValue)
PDF document to update outside the DSL context.
FontSize Nullable`1 optionalposition: namedpipeline: False
Header font size in PDF points.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated document.
Text String optionalposition: 0pipeline: False
Header text. Supports {page} and {pages}.

Outputs

OfficeIMO.Pdf.PdfDocument