How to Add Text Outline Effect to Text

A text outline effect adds a visible border around the characters of text, creating a defined outline that enhances readability or visual impact. This effect can be customized in terms of color, thickness, and style to suit design preferences. It's commonly used in graphics, typography, and digital design to make text stand out against backgrounds or to create a stylized appearance.

C# NuGet Library for

Install with NuGet

Install-Package IronWord

Add Text Outline Effect

To specify the text outline effect for the text, create the TextStyle object and populate the TextOutlineEffect property with a TextOutlineEffect object. Finally, add new text with the style by assigning the TextStyle object to the TextEffect property.

:path=/static-assets/word/content-code-examples/how-to/text-effect-text-outline-effect.cs
using IronWord;
using IronWord.Models;

// Create new Word document
WordDocument doc = new WordDocument();

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    TextOutlineEffect = TextOutlineEffect.DefaultEffect,
};

// Add text with style
doc.AddText("Hello World").Style = textStyle;

// Export new Word document
doc.SaveAs("textOutlineEffect.docx");
Imports IronWord
Imports IronWord.Models

' Create new Word document
Private doc As New WordDocument()

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {.TextOutlineEffect = TextOutlineEffect.DefaultEffect}

' Add text with style
doc.AddText("Hello World").Style = textStyle

' Export new Word document
doc.SaveAs("textOutlineEffect.docx")
VB   C#
Add text outline effect

Text Outline Effect Properties

The text outline effect offers a variety of customizable properties to suit any design need. Please find below the properties along with their descriptions:

  • PenAlignment: Gets or sets the alignment of the pen used for the outline effect.
  • LineCapType: Gets or sets the type of line cap used for the outline effect.
  • LineWidth: Gets or sets the width of the outline effect line. (Remarks: The width is specified in points (1/72 inch).)
  • CompoundLineType: Gets or sets the type of compound line used for the outline effect.
  • LineJoin: Gets or sets the stroke join style used for the outline effect.
  • Color: Gets or sets the solid fill color for the outline effect.
  • presetLineDash: Gets or sets the preset line dash style for the outline effect.
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-text-outline-effect.cs
using IronWord;
using IronWord.Models;
using IronWord.Models.Enums;

// Create new Word document
WordDocument doc = new WordDocument();

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    TextOutlineEffect = new TextOutlineEffect()
    {
        Color = IronWord.Models.Color.Red,
        CompoundLineType = CompoundLineValues.Double,
        LineCapType = LineCapValues.Round,
        LineJoin = StrokeJoinStyleValues.Bevel,
        LineWidth = 0.3,
        PenAlignment = PenAlignmentValues.Center,
        presetLineDash = PresetLineDashValues.Solid
    },
};

// Add text with style
doc.AddText("Customized text outline").Style = textStyle;

// Export new Word document
doc.SaveAs("customizedTextOutlineEffect.docx");
Imports IronWord
Imports IronWord.Models
Imports IronWord.Models.Enums

' Create new Word document
Private doc As New WordDocument()

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
	.TextOutlineEffect = New TextOutlineEffect() With {
		.Color = IronWord.Models.Color.Red,
		.CompoundLineType = CompoundLineValues.Double,
		.LineCapType = LineCapValues.Round,
		.LineJoin = StrokeJoinStyleValues.Bevel,
		.LineWidth = 0.3,
		.PenAlignment = PenAlignmentValues.Center,
		.presetLineDash = PresetLineDashValues.Solid
	}
}

' Add text with style
doc.AddText("Customized text outline").Style = textStyle

' Export new Word document
doc.SaveAs("customizedTextOutlineEffect.docx")
VB   C#
Customized text outline effect