API Reference
Cmdlet
Set-OfficePdfHeader
Sets a simple or fully composed running PDF header.
Remarks
Sets a simple or fully composed running PDF header.
Examples
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:
ContextParameters
- Align PdfAlign
- Header alignment. Possible values: Left, Center, Right, Justify
- Possible values:
Left,Center,Right,Justify - Compose ScriptBlock
- 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
- Header font size in PDF points.
- PassThru SwitchParameter
- Emit the updated document.
- Text String
- 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:
DocumentParameters
- Align PdfAlign
- Header alignment. Possible values: Left, Center, Right, Justify
- Possible values:
Left,Center,Right,Justify - Compose ScriptBlock
- 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
- PDF document to update outside the DSL context.
- FontSize Nullable`1
- Header font size in PDF points.
- PassThru SwitchParameter
- Emit the updated document.
- Text String
- Header text. Supports {page} and {pages}.
Outputs
OfficeIMO.Pdf.PdfDocument