Add-OfficePdfCanvasText
Adds PowerShell-friendly text or rich text runs to the active fixed-position PDF canvas.
Syntax
Add-OfficePdfCanvasText
[-Align <Left| Center| Right| Justify>]
[-BackgroundColor <String>]
[-Baseline <Normal| Superscript| Subscript>]
[-Bold]
[-Color <String>]
[-Font <PdfStandardFont>]
[-FontSize <Double>]
[-Height <Double>]
[-Italic]
[-LineHeight <Double>]
[-PassThru]
[-Strike]
[-Text] <String[]>
[-Underline]
[-Width <Double>]
-X <Double>
-Y <Double>
[<CommonParameters>]#TextAdd-OfficePdfCanvasText
[-Align <Left| Center| Right| Justify>]
[-Color <String>]
[-FontSize <Double>]
[-Height <Double>]
[-LineHeight <Double>]
[-PassThru]
-Run <Object[]>
[-Width <Double>]
-X <Double>
-Y <Double>
[<CommonParameters>]#RunDescription
Use this command inside Add-OfficePdfCanvas -Content. Coordinates are PDF points measured from the visual top-left of the page. Rich runs accept TextRun output, hashtables, and objects; callers do not need to construct native PdfTextRun arrays. Fixed-position canvas runs are visual text and do not support link targets. Width and height default to the remaining page area from the supplied coordinates.
Examples
Place mixed-format text on each selected page.
Add-OfficePdfCanvas -Path .\Report.pdf -OutputPath .\Stamped.pdf -Content {
PdfCanvasText -Run @(
TextRun 'Owner: ' -Bold
TextRun 'Platform' -Color '#0F766E'
) -X 36 -Y 24 -FontSize 10
}The enclosing callback supplies the active page, while the run collection remains an ordinary PowerShell array.
Parameters
- -Align PdfAlign
- Text alignment within the positioned rectangle.
- Possible values:
Left,Center,Right,Justify - -BackgroundColor String
- Background color for plain -Text input.
- -Baseline PdfTextBaseline
- Baseline for plain -Text input.
- Possible values:
Normal,Superscript,Subscript - -Bold SwitchParameter
- Make plain -Text input bold.
- -Color String
- Default text color. Named and hexadecimal colors are accepted.
- -Font PdfStandardFont
- Standard PDF font for plain -Text input.
- Possible values:
Helvetica,HelveticaOblique,HelveticaBold,HelveticaBoldOblique,TimesRoman,TimesItalic,TimesBold,TimesBoldItalic,Courier,CourierOblique,CourierBold,CourierBoldOblique - -FontSize Double
- Default font size in PDF points.
- -Height Double
- Available text height in PDF points. Defaults to the remaining page height.
- -Italic SwitchParameter
- Make plain -Text input italic.
- -LineHeight Double
- Optional line height in PDF points.
- -PassThru SwitchParameter
- Emit the object created or changed by the command.
- -Strike SwitchParameter
- Strike through plain -Text input.
- -Text String[]
- Plain text values to concatenate into one positioned text block.
- -Underline SwitchParameter
- Underline plain -Text input.
- -Width Double
- Available text width in PDF points. Defaults to the remaining page width.
- -X Double
- Horizontal position in PDF points from the visual left edge.
- -Y Double
- Vertical position in PDF points from the visual top edge.
- -Run Object[]
- Rich run specifications created with TextRun or supplied as hashtables or objects. Link targets are not supported.
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.