Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

PdfTextRun

OfficeIMO.Pdf

Namespace
OfficeIMO.Pdf
Assembly
OfficeIMO.Pdf
Source revision
ac7e6e1bad8a with working tree changes
Modifiers
sealed

Inline text segment with basic styling.

Inheritance

  • object
  • PdfTextRun

Usage

Explore 83 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 50

Accepted by parameters 33

Constructors

public PdfTextRun(string text, bool bold = false, bool underline = false, OfficeColor? color = null, bool italic = false, bool strike = false, OfficeLength? fontSize = null, PdfStandardFont? standardFont = null, string? linkUri = null, string? linkContents = null, PdfTextBaseline baseline = Normal, string? linkDestinationName = null, PdfTabLeaderStyle tabLeader = None, PdfTabAlignment tabAlignment = Left, OfficeColor? backgroundColor = null, string? fontFamily = null, OfficeTextDecorationStyle underlineStyle = None, OfficeTextDecorationStyle strikeStyle = None, OfficeColor? decorationColor = null) #

Create a new run with the specified styles and tab alignment.

Parameters

text string required
bold bool = false optional
underline bool = false optional
color OfficeIMO.OfficeColor? = null optional
italic bool = false optional
strike bool = false optional
fontSize OfficeIMO.OfficeLength? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
linkUri string? = null optional
linkContents string? = null optional
baseline OfficeIMO.Pdf.PdfTextBaseline = Normal optional
linkDestinationName string? = null optional
tabLeader OfficeIMO.Pdf.PdfTabLeaderStyle = None optional
tabAlignment OfficeIMO.Pdf.PdfTabAlignment = Left optional
backgroundColor OfficeIMO.OfficeColor? = null optional
fontFamily string? = null optional
underlineStyle OfficeIMO.Drawing.OfficeTextDecorationStyle = None optional
strikeStyle OfficeIMO.Drawing.OfficeTextDecorationStyle = None optional
decorationColor OfficeIMO.OfficeColor? = null optional

Methods

public static PdfTextRun Bolded(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a bold run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun BoldItalic(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a bold and italic run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun BoldUnderlined(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a bold and underlined run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun Inline(PdfInlineElement element) #

Create an inline visual run.

Parameters

element OfficeIMO.Pdf.PdfInlineElement required

Returns

PdfTextRun
public static PdfTextRun Italicized(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create an italic run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun LineBreak() #

Create an explicit line-break run.

Returns

PdfTextRun
public static PdfTextRun LinkToBookmark(string text, string bookmarkName, OfficeColor? color = null, bool underline = true, string? contents = null, PdfTextBaseline baseline = Normal, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null, OfficeTextDecorationStyle underlineStyle = None, OfficeTextDecorationStyle strikeStyle = None) #

Create a hyperlink run that points to a document bookmark with native decoration styles.

Parameters

text string required
Link text.
bookmarkName string required
Named destination created with PdfDocument.Bookmark.
color OfficeIMO.OfficeColor? = null optional
Optional link color.
underline bool = true optional
Whether to underline the link text.
contents string? = null optional
Optional link annotation contents.
baseline OfficeIMO.Pdf.PdfTextBaseline = Normal optional
Baseline placement for this run.
fontSize OfficeIMO.OfficeLength? = null optional
Optional physical run font size.
backgroundColor OfficeIMO.OfficeColor? = null optional
Optional run background color.
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
Optional standard font for this run.
fontFamily string? = null optional
Optional registered embedded family name. standardFont remains its fallback.
underlineStyle OfficeIMO.Drawing.OfficeTextDecorationStyle = None optional
Optional underline pattern.
strikeStyle OfficeIMO.Drawing.OfficeTextDecorationStyle = None optional
Optional strikethrough pattern.

Returns

PdfTextRun
public static PdfTextRun Normal(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a normal (unstyled) run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public PdfTextRun SetBackgroundColor(OfficeColor color) #

Sets the background (highlight) colour of this run.

Parameters

color OfficeIMO.OfficeColor required

Returns

PdfTextRun
public PdfTextRun SetBaseline(PdfTextBaseline baseline) #

Sets the baseline placement of this run.

Parameters

baseline OfficeIMO.Pdf.PdfTextBaseline required

Returns

PdfTextRun
public PdfTextRun SetBold(bool bold = true) #

Makes this run bold or regular weight.

Parameters

bold bool = true optional

Returns

PdfTextRun
public PdfTextRun SetCharacterSpacing(OfficeLength spacing) #

Sets the additional advance after each glyph of this text run. Zero is normal spacing.

Parameters

spacing OfficeIMO.OfficeLength required

Returns

PdfTextRun
public PdfTextRun SetColor(OfficeColor color) #

Sets the foreground colour of this run.

Parameters

color OfficeIMO.OfficeColor required

Returns

PdfTextRun
public PdfTextRun SetFontFamily(string fontFamily) #

Sets the registered embedded font family of this run. PdfTextRun.StandardFont remains its fallback.

Parameters

fontFamily string required

Returns

PdfTextRun
public PdfTextRun SetFontSize(OfficeLength fontSize) #

Sets the font size of this run.

Parameters

fontSize OfficeIMO.OfficeLength required

Returns

PdfTextRun
public PdfTextRun SetHorizontalTextScaling(double percentage) #

Sets the horizontal glyph width percentage of this text run. 100 is normal width.

Parameters

percentage double required

Returns

PdfTextRun
public PdfTextRun SetItalic(bool italic = true) #

Makes this run italic or upright.

Parameters

italic bool = true optional

Returns

PdfTextRun
public PdfTextRun SetStandardFont(PdfStandardFont standardFont) #

Sets the standard PDF font of this run.

Parameters

standardFont OfficeIMO.Pdf.PdfStandardFont required

Returns

PdfTextRun
SetStrikethrough 2 overloads
public PdfTextRun SetStrikethrough(bool strikethrough = true) #

Adds a single strikethrough to this run, or removes its strikethrough.

Parameters

strikethrough bool = true optional

Returns

PdfTextRun
public PdfTextRun SetStrikethrough(OfficeTextDecorationStyle style) #

Sets the strikethrough pattern of this run. OfficeTextDecorationStyle.None removes it.

Parameters

style OfficeIMO.Drawing.OfficeTextDecorationStyle required

Returns

PdfTextRun
public PdfTextRun SetSubscript() #

Lowers this run to subscript.

Returns

PdfTextRun
public PdfTextRun SetSuperscript() #

Raises this run to superscript.

Returns

PdfTextRun
SetUnderline 2 overloads
public PdfTextRun SetUnderline(bool underline = true) #

Adds a single underline to this run, or removes its underline.

Parameters

underline bool = true optional

Returns

PdfTextRun
public PdfTextRun SetUnderline(OfficeTextDecorationStyle style) #

Sets the underline pattern of this run. OfficeTextDecorationStyle.None removes it.

Parameters

style OfficeIMO.Drawing.OfficeTextDecorationStyle required

Returns

PdfTextRun
public static PdfTextRun Strikethrough(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a strikethrough run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun Subscript(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a subscript run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun Superscript(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create a superscript run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public static PdfTextRun Tab(PdfTabLeaderStyle leader = None, PdfTabAlignment alignment = Left) #

Create an explicit paragraph tab run with alignment.

Parameters

leader OfficeIMO.Pdf.PdfTabLeaderStyle = None optional
alignment OfficeIMO.Pdf.PdfTabAlignment = Left optional

Returns

PdfTextRun
public static PdfTextRun Underlined(string text, OfficeColor? color = null, OfficeLength? fontSize = null, OfficeColor? backgroundColor = null, PdfStandardFont? standardFont = null, string? fontFamily = null) #

Create an underlined run.

Parameters

text string required
color OfficeIMO.OfficeColor? = null optional
fontSize OfficeIMO.OfficeLength? = null optional
backgroundColor OfficeIMO.OfficeColor? = null optional
standardFont OfficeIMO.Pdf.PdfStandardFont? = null optional
fontFamily string? = null optional

Returns

PdfTextRun
public PdfTextRun WithCharacterSpacing(OfficeLength spacing) #

Creates a copy with additional advance after each rendered glyph, as a physical length.

Parameters

spacing OfficeIMO.OfficeLength required
Finite positive or negative spacing. Negative values condense the glyph advances.

Returns

PdfTextRun
public PdfTextRun WithFeatureSettings(OfficeTextFeatureSettings featureSettings) #

Creates a copy with explicit OpenType feature selections.

Parameters

featureSettings OfficeIMO.Drawing.OfficeTextFeatureSettings required

Returns

PdfTextRun
public PdfTextRun WithFootnoteReference(PdfFootnoteDefinition definition) #

Creates a copy associated with a footnote while retaining text, typography, spacing, and links.

Parameters

definition OfficeIMO.Pdf.PdfFootnoteDefinition required

Returns

PdfTextRun
public PdfTextRun WithHorizontalTextScaling(double percentage) #

Creates a copy with a positive horizontal glyph width percentage, preserving font height and other formatting.

Parameters

percentage double required

Returns

PdfTextRun
public PdfTextRun WithTextCase(OfficeTextCase textCase, CultureInfo? culture = null) #

Create a copy with transformed text casing while preserving all run formatting and link metadata.

Parameters

textCase OfficeIMO.Drawing.OfficeTextCase required
culture System.Globalization.CultureInfo? = null optional

Returns

PdfTextRun

Properties

public string Text { get; } #

Text content of this run.

public bool Bold { get; private set; } #

True when bold style is applied.

public bool Underline { get; } #

True when underline is applied.

public OfficeTextDecorationStyle UnderlineStyle { get; private set; } #

Underline pattern rendered by the PDF writer.

public bool Strike { get; } #

True when strikethrough is applied.

public OfficeTextDecorationStyle StrikeStyle { get; private set; } #

Strikethrough pattern rendered by the PDF writer.

public OfficeColor? DecorationColor { get; } #

Optional underline and strikethrough color. Null uses the run foreground color.

public bool Italic { get; private set; } #

True when italic style is applied.

public OfficeColor? Color { get; private set; } #

Run foreground color (if any).

public OfficeColor? BackgroundColor { get; private set; } #

Optional run background color, useful for highlights.

public OfficeLength? FontSize { get; private set; } #

Optional font size for this run. When null, the paragraph font size is used.

public PdfStandardFont? StandardFont { get; private set; } #

Optional standard PDF font for this run. When null, the paragraph/document font is used.

public string? FontFamily { get; private set; } #

Optional registered embedded font family for this run. This does not consume a standard-font compatibility slot; PdfTextRun.StandardFont remains the fallback when the family is unavailable.

public string? LinkUri { get; } #

Optional hyperlink URI associated with this run.

public string? LinkDestinationName { get; } #

Optional named destination associated with this run.

public string? LinkContents { get; } #

Optional hyperlink annotation contents, used by readers as link metadata.

public PdfTextBaseline Baseline { get; private set; } #

Baseline placement for this run.

public PdfTabLeaderStyle TabLeader { get; } #

Leader fill used when this run represents a paragraph tab.

public PdfTabAlignment TabAlignment { get; } #

Alignment used when this run represents a paragraph tab.

public PdfInlineElement? InlineElement { get; } #

Optional inline visual carried by this run instead of text.

public OfficeTextFeatureSettings FeatureSettings { get; private set; } #

Optional OpenType feature selections for this run.

public PdfFootnoteDefinition? FootnoteReference { get; private set; } #

The page-associated footnote referenced by this run, or null.

public double HorizontalTextScaling { get; private set; } #

Horizontal glyph width as a percentage of the selected font's normal width. The default is 100.

public OfficeLength CharacterSpacing { get; private set; } #

Additional advance after each rendered glyph, as a physical length. The default is zero.