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.

Get started with IronWord

Start using IronWord in your project today with a free trial.

First Step:
green arrow pointer


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")
$vbLabelText   $csharpLabel
Add text outline effect

Text Outline Effect Properties

The text outline effect offers a variety of customizable properties to suit any design need. Below are 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. Note: 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")
$vbLabelText   $csharpLabel
Customized text outline effect

Frequently Asked Questions

What is a text outline effect in a Word document?

A text outline effect in a Word document adds a visible border around text characters, enhancing their readability and visual impact. This effect is customizable in terms of color, thickness, and style to better suit design preferences.

How can I apply a text outline effect in C#?

In C#, you can apply a text outline effect by using the TextOutlineEffect class in IronWord. You can configure its properties such as color, line width, and style to customize the effect for your text.

What are the steps to add a text outline effect using IronWord?

The steps include downloading the IronWord library, applying the text effect to new or existing text, configuring the TextOutlineEffect properties, and exporting the edited document as a new file.

Can I customize the properties of a text outline effect in C#?

Yes, you can customize the text outline effect by adjusting properties like PenAlignment, LineCapType, LineWidth, CompoundLineType, LineJoin, Color, and PresetLineDash using IronWord.

What is the unit of measurement for line width in a text outline effect?

The line width for a text outline effect is measured in points, where one point is equivalent to 1/72 of an inch.

How do I export a Word document after applying a text outline effect?

After applying a text outline effect in IronWord, you can export the edited Word document using the library's export functions to save your changes as a new file.

What is the purpose of using text outline effects in design?

Text outline effects are used to make text stand out against backgrounds or to create a stylized appearance, enhancing the readability and visual impact in digital design.

How do I define a text style with a text outline effect in C#?

You can define a text style by creating a TextStyle object and populating its TextOutlineEffect property with a TextOutlineEffect object. Assign this style to your text through the TextEffect property.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.