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.
How to Add Text Outline Effect to Text
- Download a C# library to add a text outline to text
- Apply the text effect to either newly created or existing text
- Apply a preset text outline effect using the static named instance of the TextOutlineEffect class
- Configure the TextOutlineEffect properties to achieve a customized text outline
- Export the edited Word document as a new file
Install with NuGet
Install-Package IronWord
Install with NuGet
Install-Package IronWord
Download DLL
Manually install into your project
Start using IronPDF in your project today with a free trial.
Check out IronWord on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming with C#.
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")
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")