Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficePdfText

Aliases: PdfText
Module PSWriteOffice
Aliases
PdfText
Inputs
OfficeIMO.Pdf.PdfDocument
Outputs
OfficeIMO.Pdf.PdfDocument

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>]
#
Parameter set: Context
Add-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>]
#
Parameter set: Document

Description

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

Authored help example

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 optional
Paragraph alignment.
Possible values: Left, Center, Right, Justify
-BackgroundColor String optional
Run background color for -Text input. Named colors and hexadecimal colors are accepted.
-Baseline PdfTextBaseline optional
Baseline for -Text input.
Possible values: Normal, Superscript, Subscript
-Bold SwitchParameter optional
Make -Text input bold.
-Color String optional
Default paragraph color. Named colors and hexadecimal colors are accepted.
-Font PdfStandardFont optional
Standard PDF font for -Text input.
Possible values: Helvetica, HelveticaOblique, HelveticaBold, HelveticaBoldOblique, TimesRoman, TimesItalic, TimesBold, TimesBoldItalic, Courier, CourierOblique, CourierBold, CourierBoldOblique
-FontSize Double optional
Font size for -Text input in PDF points.
-Italic SwitchParameter optional
Make -Text input italic.
-LinkContents String optional
Optional link annotation contents for -Text input.
-LinkDestinationName String optional
Named destination link target for -Text input.
-LinkUri String optional
Absolute URI link target for -Text input.
-PassThru SwitchParameter optional
Emit the updated document.
-Run Object[] optionalaliases: Runs
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 optional
Strike through -Text input.
-Text String[] optionalposition: 0
Plain text values to add as one styled paragraph.
-Underline SwitchParameter optional
Underline -Text input.
-Document PdfDocument requiredpipeline: True (ByValue)sets: Document
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.