How to Add Shadow Effect to Text
The Shadow Effect on text is a visual enhancement technique used to create depth and distinction for text elements. When applied, it introduces a duplicated version of the text behind the original, slightly offset to give the appearance of a shadow. This secondary text, known as the shadow, can be adjusted in several ways to achieve different visual effects.
Get started with IronWord
Start using IronWord in your project today with a free trial.
How to Add Shadow Effect to Text
- Download a C# library to add a shadow effect to text
- Apply the text effect to either newly created or existing text
- Apply a preset shadow effect using the static named instance of the Shadow class
- Configure the Shadow properties to achieve a customized shadow
- Export the edited Word document as a new file
Add Shadow Effect
To specify the shadow effect for the text, create the TextStyle object and populate the ShadowEffect property with a Shadow 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-shadow-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()
{
ShadowEffect = Shadow.OuterShadow1,
};
// Add text with style
doc.AddText("Hello World").Style = textStyle;
// Export new Word document
doc.SaveAs("shadowEffect.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 {.ShadowEffect = Shadow.OuterShadow1}
' Add text with style
doc.AddText("Hello World").Style = textStyle
' Export new Word document
doc.SaveAs("shadowEffect.docx")

Shadow Effect Properties
Besides assigning a predefined shadow value, all of the shadow effect's properties can be configured. This provides a very flexible option to customize the shadow effect in any way possible. Please see the properties and their descriptions below:
- Alignment: Gets or sets the alignment of the shadow.
- BlurRadius: Gets or sets the blur radius of the shadow effect. The blur radius is specified in points (1/72 inch).
- DirectionAngle: Gets or sets the direction angle of the shadow effect. The direction angle is specified in degrees.
- DistanceFromText: Gets or sets the distance of the shadow effect from the text or object. The distance is specified in points (1/72 inch).
- HorizontalScalingFactor: Gets or sets the horizontal scaling factor of the shadow effect.
- HorizontalSkewAngle: Gets or sets the horizontal skew angle of the shadow effect. The skew angle is specified in degrees.
- SchemeColor: Gets or sets the scheme color of the shadow effect.
- VerticalScalingFactor: Gets or sets the vertical scaling factor of the shadow effect.
- VerticalSkewAngle: Gets or sets the vertical skew angle of the shadow effect. The skew angle is specified in degrees.
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-shadow-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()
{
ShadowEffect = new Shadow()
{
Alignment = RectangleAlignmentValues.BottomLeft,
BlurRadius = 5,
DirectionAngle = 45,
DistanceFromText = 3,
HorizontalScalingFactor = 100,
VerticalScalingFactor = 100,
HorizontalSkewAngle = 0,
SchemeColor = IronWord.Models.Color.Aqua,
VerticalSkewAngle = 0,
},
};
// Add text with style
doc.AddText("Customized shadow").Style = textStyle;
// Export new Word document
doc.SaveAs("customizedShadowEffect.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 {
.ShadowEffect = New Shadow() With {
.Alignment = RectangleAlignmentValues.BottomLeft,
.BlurRadius = 5,
.DirectionAngle = 45,
.DistanceFromText = 3,
.HorizontalScalingFactor = 100,
.VerticalScalingFactor = 100,
.HorizontalSkewAngle = 0,
.SchemeColor = IronWord.Models.Color.Aqua,
.VerticalSkewAngle = 0
}
}
' Add text with style
doc.AddText("Customized shadow").Style = textStyle
' Export new Word document
doc.SaveAs("customizedShadowEffect.docx")

Frequently Asked Questions
How can I add a shadow effect to text in C#?
You can add a shadow effect to text in C# by using the IronWord library. First, download the library, then apply the shadow effect using the Shadow
class. Configure the properties as needed and export your document with the applied effects.
What are the customizable properties of a shadow effect in IronWord?
IronWord allows you to customize several properties of the shadow effect, including Alignment
, BlurRadius
, DirectionAngle
, DistanceFromText
, HorizontalScalingFactor
, HorizontalSkewAngle
, SchemeColor
, VerticalScalingFactor
, and VerticalSkewAngle
.
How do I apply a preset shadow effect using IronWord?
To apply a preset shadow effect using IronWord, use the static named instance of the Shadow
class and configure its properties to fit your needs.
Can I apply a shadow effect to existing text in a Word document?
Yes, you can apply a shadow effect to both newly created and existing text in a Word document using IronWord by creating a TextStyle
object and populating the ShadowEffect
property with a Shadow
object.
What is the role of the BlurRadius
property in a shadow effect?
The BlurRadius
property in a shadow effect specifies the blur radius in points (1/72 inch), which determines how soft or sharp the shadow appears.
How do I control the direction of a shadow effect in a Word document?
To control the direction of a shadow effect in IronWord, set the DirectionAngle
property, which is specified in degrees, to orient the shadow as desired.
Is it possible to align the shadow differently from the text?
Yes, IronWord's Alignment
property allows you to set the alignment of the shadow relative to the text, providing flexibility in how the shadow is positioned.
How do I set the color of a shadow effect to match my document theme?
Use the SchemeColor
property in IronWord to set the color scheme of the shadow effect, allowing the shadow to match the overall design theme of your document.
What does the DistanceFromText
property control in a shadow effect?
The DistanceFromText
property controls the distance of the shadow from the text or object, measured in points (1/72 inch), affecting how far the shadow appears from the text.