Cómo Añadir Efecto de Sombra al Texto en C# | IronWord

How to Add Shadow Effect to Text

This article was translated from English: Does it need improvement?
Translated
View the article in English

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.

Quickstart: Add a Preset Shadow Effect in One Line

Here’s how to enhance your Word document text with a shadow using IronWord—just one line to define style and shadow, plus save. Ideal for devs who want results fast with minimal setup.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronWord with NuGet Package Manager

    PM > Install-Package IronWord

  2. Copy and run this code snippet.

    new IronWord.WordDocument().AddText("Shadow!").Style = new IronWord.Models.TextStyle { TextEffect = new IronWord.Models.TextEffect { ShadowEffect = IronWord.Models.Shadow.OuterShadow1 } };
  3. Deploy to test on your live environment

    Start using IronWord in your project today with a free trial
    arrow pointer

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")
$vbLabelText   $csharpLabel
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")
$vbLabelText   $csharpLabel
Customized shadow effect

Preguntas Frecuentes

¿Cómo puedo agregar un efecto de sombra al texto en C#?

Puedes agregar un efecto de sombra al texto en C# usando la biblioteca IronWord. Primero, descarga la biblioteca, luego aplica el efecto de sombra usando la clase Shadow. Configura las propiedades según sea necesario y exporta tu documento con los efectos aplicados.

¿Cuáles son las propiedades personalizables de un efecto de sombra en IronWord?

IronWord te permite personalizar varias propiedades del efecto de sombra, incluyendo Alignment, BlurRadius, DirectionAngle, DistanceFromText, HorizontalScalingFactor, HorizontalSkewAngle, SchemeColor, VerticalScalingFactor, y VerticalSkewAngle.

¿Cómo aplico un efecto de sombra predefinido usando IronWord?

Para aplicar un efecto de sombra predefinido usando IronWord, utiliza la instancia estática con nombre de la clase Shadow y configura sus propiedades para adaptarlas a tus necesidades.

¿Puedo aplicar un efecto de sombra al texto existente en un documento Word?

Sí, puedes aplicar un efecto de sombra tanto al texto recién creado como al texto existente en un documento Word usando IronWord al crear un objeto TextStyle y poblar la propiedad ShadowEffect con un objeto Shadow.

¿Cuál es el papel de la propiedad BlurRadius en un efecto de sombra?

La propiedad BlurRadius en un efecto de sombra especifica el radio de desenfoque en puntos (1/72 de pulgada), lo que determina cuán suave o definido aparece la sombra.

¿Cómo controlo la dirección de un efecto de sombra en un documento Word?

Para controlar la dirección de un efecto de sombra en IronWord, establece la propiedad DirectionAngle, que se especifica en grados, para orientar la sombra como desees.

¿Es posible alinear la sombra de forma diferente al texto?

Sí, la propiedad Alignment de IronWord te permite establecer la alineación de la sombra con respecto al texto, proporcionando flexibilidad en cómo se posiciona la sombra.

¿Cómo configuro el color de un efecto de sombra para que coincida con el tema de mi documento?

Usa la propiedad SchemeColor en IronWord para establecer el esquema de color del efecto de sombra, permitiendo que la sombra coincida con el tema de diseño general de tu documento.

¿Qué controla la propiedad DistanceFromText en un efecto de sombra?

La propiedad DistanceFromText controla la distancia de la sombra desde el texto u objeto, medida en puntos (1/72 de pulgada), afectando la distancia a la que la sombra aparece desde el texto.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 25,807 | Versión: 2025.11 recién lanzado