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.

C# NuGet Library for

Install with NuGet

Install-Package IronWord

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")
VB   C#
Add shadow effect

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")
VB   C#
Customized shadow effect