# Set-OfficePdfHeader

Sets a simple or fully composed running PDF header.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: PdfHeader

**Module**

`PSWriteOffice`

**Aliases**

`PdfHeader`

**Inputs**

`OfficeIMO.Pdf.PdfDocument`

**Outputs**

`OfficeIMO.Pdf.PdfDocument`

**Source**

[SetOfficePdfHeaderCommand.cs:40](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Pdf/SetOfficePdfHeaderCommand.cs#L40) 

Sets a simple or fully composed running PDF header.

## Syntax

```
Set-OfficePdfHeader
[-Align <Left|Center|Right|Justify>]
[-Compose <ScriptBlock>]
[-FontSize <Double>]
[-PassThru]
[[-Text] <String>]
[<CommonParameters>]
```

[#](#method-set-officepdfheader-pdfalign-scriptblock-double-switchparameter-string)

Parameter set: `Context`

```
Set-OfficePdfHeader
[-Align <Left|Center|Right|Justify>]
[-Compose <ScriptBlock>]
-Document <PdfDocument>
[-FontSize <Double>]
[-PassThru]
[[-Text] <String>]
[<CommonParameters>]
```

[#](#method-set-officepdfheader-pdfalign-scriptblock-pdfdocument-double-switchparameter-string)

Parameter set: `Document`

## Examples

### Add a running report header.

```powershell
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.

### Compose styled default, first-page, and even-page headers.

```powershell
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.

## Parameters

**-Align PdfAlign optional**

Header alignment.

Possible values: `Left`, `Center`, `Right`, `Justify`

**-Compose ScriptBlock optional**

Advanced header composer. The script receives a PdfHeaderBuilder and can configure default, first-page, and even-page text, zones, images, shapes, rich text, and page tokens.

**-FontSize Double optional**

Header font size in PDF points.

**-PassThru SwitchParameter optional**

Emit the updated document.

**-Text String optionalposition: 0**

Header text. Supports {page} and {pages}.

**-Document PdfDocument requiredpipeline: True (ByValue)sets: Document**

Compatibility parameter. Page composition is supported only inside New-OfficePdf.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:3CC81ADEDB451DC791D3A9505872F36820596E4449C9D61EA43F540D38CE96E0 -->
