Project

PSWriteOffice

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

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Add-OfficePdfCanvasText

Aliases: PdfCanvasText
Module
PSWriteOffice
Aliases
PdfCanvasText
Inputs
None

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>]
#
Parameter set: Text
Add-OfficePdfCanvasText
[-Align <Left|Center|Right|Justify>]
[-Color <String>]
[-FontSize <Double>]
[-Height <Double>]
[-LineHeight <Double>]
[-PassThru]
-Run <Object[]>
[-Width <Double>]
-X <Double>
-Y <Double>
[<CommonParameters>]
#
Parameter set: Run

Description

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 optional
Text alignment within the positioned rectangle.
Possible values: Left, Center, Right, Justify
-BackgroundColor String optionalsets: Text
Background color for plain -Text input.
-Baseline PdfTextBaseline optionalsets: Text
Baseline for plain -Text input.
Possible values: Normal, Superscript, Subscript
-Bold SwitchParameter optionalsets: Text
Make plain -Text input bold.
-Color String optional
Default text color. Named and hexadecimal colors are accepted.
-Font PdfStandardFont optionalsets: Text
Standard PDF font for plain -Text input.
Possible values: Helvetica, HelveticaOblique, HelveticaBold, HelveticaBoldOblique, TimesRoman, TimesItalic, TimesBold, TimesBoldItalic, Courier, CourierOblique, CourierBold, CourierBoldOblique
-FontSize Double optional
Default font size in PDF points.
-Height Double optional
Available text height in PDF points. Defaults to the remaining page height.
-Italic SwitchParameter optionalsets: Text
Make plain -Text input italic.
-LineHeight Double optional
Optional line height in PDF points.
-PassThru SwitchParameter optional
Emit the object created or changed by the command.
-Strike SwitchParameter optionalsets: Text
Strike through plain -Text input.
-Text String[] requiredposition: 0sets: Text
Plain text values to concatenate into one positioned text block.
-Underline SwitchParameter optionalsets: Text
Underline plain -Text input.
-Width Double optional
Available text width in PDF points. Defaults to the remaining page width.
-X Double requiredaliases: Left
Horizontal position in PDF points from the visual left edge.
-Y Double requiredaliases: Top
Vertical position in PDF points from the visual top edge.
-Run Object[] requiredaliases: Runssets: Run
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.