Add-OfficePdfText
Adds a rich inline-text paragraph to a generated PDF document.
Syntax
Add-OfficePdfText [-Align <Left|Center|Right|Justify>] [-BackgroundColor <String>] [-Baseline <Normal|Superscript|Subscript>] [-Bold] [-Color <String>] [-Font <PdfStandardFont>] [-FontSize <Double>] [-Italic] [-LinkContents <String>] [-LinkDestinationName <String>] [-LinkUri <String>] [-PassThru] [-Run <Object[]>] [-Strike] [[-Text] <String[]>] [-Underline] [<CommonParameters>]#ContextAdd-OfficePdfText [-Align <Left|Center|Right|Justify>] [-BackgroundColor <String>] [-Baseline <Normal|Superscript|Subscript>] [-Bold] [-Color <String>] -Document <PdfDocument> [-Font <PdfStandardFont>] [-FontSize <Double>] [-Italic] [-LinkContents <String>] [-LinkDestinationName <String>] [-LinkUri <String>] [-PassThru] [-Run <Object[]>] [-Strike] [[-Text] <String[]>] [-Underline] [<CommonParameters>]#DocumentDescription
Use Add-OfficePdfText when a paragraph needs mixed emphasis, highlight color, font settings, baseline changes, or links. Plain paragraphs can continue to use Add-OfficePdfParagraph. Rich text runs are translated directly to the OfficeIMO.Pdf paragraph builder. URI links and bookmark links are supported; a single run cannot target both.
Examples
Add styled text with the DSL alias.
New-OfficePdf -Path .\Report.pdf { PdfText 'Approved for review' -Bold -Color '#0F766E' -BackgroundColor '#ECFDF5' }Creates a PDF with one styled paragraph.
Add mixed rich runs with URI and bookmark links.
New-OfficePdf -Path .\Report.pdf {
PdfBookmark 'summary'
PdfText -Run @(
@{ Text = 'Read the ' }
@{ Text = 'website'; LinkUri = 'https://evotec.xyz'; Color = '#2563EB' }
@{ Text = ' or jump to ' }
@{ Text = 'summary'; LinkDestinationName = 'summary'; Color = '#7C3AED' }
@{ Text = '.' }
)
}Creates one paragraph with an external link and an internal named-destination link.
Parameters
- -Align PdfAlign
- Paragraph alignment.
- Possible values:
Left,Center,Right,Justify - -BackgroundColor String
- Run background color for -Text input. Named colors and hexadecimal colors are accepted.
- -Baseline PdfTextBaseline
- Baseline for -Text input.
- Possible values:
Normal,Superscript,Subscript - -Bold SwitchParameter
- Make -Text input bold.
- -Color String
- Default paragraph color. Named colors and hexadecimal colors are accepted.
- -Font PdfStandardFont
- Standard PDF font for -Text input.
- Possible values:
Helvetica,HelveticaOblique,HelveticaBold,HelveticaBoldOblique,TimesRoman,TimesItalic,TimesBold,TimesBoldItalic,Courier,CourierOblique,CourierBold,CourierBoldOblique - -FontSize Double
- Font size for -Text input in PDF points.
- -Italic SwitchParameter
- Make -Text input italic.
- -LinkContents String
- Optional link annotation contents for -Text input.
- -LinkDestinationName String
- Named destination link target for -Text input.
- -LinkUri String
- Absolute URI link target for -Text input.
- -PassThru SwitchParameter
- Emit the updated document.
- -Run Object[]
- Rich run specifications. Each run may define Text, Bold, Italic, Underline, Strike, Color, BackgroundColor, FontSize, Font, Baseline, LinkUri, LinkDestinationName, LinkContents, Type, or Kind.
- -Strike SwitchParameter
- Strike through -Text input.
- -Text String[]
- Plain text values to add as one styled paragraph.
- -Underline SwitchParameter
- Underline -Text input.
- -Document PdfDocument
- PDF document to update outside the DSL context.
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.