Comment ajouter l'effet de réflexion au texte en C# | IronWord

How to Add Reflection Effect to Text

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

A reflection effect on text is a visual enhancement that creates a mirror-like image of the text below its original form. This effect simulates the reflection of the text on a surface, often adding depth and realism to the design.

Quickstart: Apply Reflection Effect to Text in C#

With just one line of code using IronWord, you can apply a preset reflection effect to any text. Developers get up and running instantly—no complex setup or boilerplate code needed.

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("Quick Text").Style = new IronWord.Models.TextStyle(){ TextEffect = new IronWord.Models.TextEffect(){ ReflectionEffect = new IronWord.Models.Reflection() } };
  3. Deploy to test on your live environment

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

Add Reflection Effect

To specify the reflection effect for the text, create the TextStyle object and populate the ReflectionEffect property with a Reflection 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-reflection-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()
{
    ReflectionEffect = new Reflection(),
};

// Add text with style
doc.AddText("Hello World").Style = textStyle;

// Export new Word document
doc.SaveAs("reflectionEffect.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 {.ReflectionEffect = New Reflection()}

' Add text with style
doc.AddText("Hello World").Style = textStyle

' Export new Word document
doc.SaveAs("reflectionEffect.docx")
$vbLabelText   $csharpLabel
Add reflection effect

Reflection Effect Properties

The reflection effect provides a range of adjustable attributes to meet diverse design requirements. See the following list for detailed descriptions of each property:

  • SchemeColor: Gets or sets the scheme color of the reflection effect.
  • HorizontalSkewAngle: Gets or sets the horizontal skew angle of the reflection effect. The skew angle is specified in degrees.
  • HorizontalScalingFactor: Gets or sets the horizontal scaling factor of the reflection effect.
  • DistanceFromText: Gets or sets the distance of the reflection effect from the text or object. The distance is specified in points (1/72 inch).
  • DirectionAngle: Gets or sets the direction angle of the reflection effect. The direction angle is specified in degrees.
  • FadeDirectionAngle: Gets or sets the fade direction of the reflection effect.
  • EndPosition: Gets or sets the ending position of the reflection effect.
  • StartPosition: Gets or sets the starting position of the reflection effect.
  • EndingOpacity: Gets or sets the ending opacity of the reflection effect.
  • VerticalScalingFactor: Gets or sets the vertical scaling factor of the reflection effect.
  • StartingOpacity: Gets or sets the starting opacity of the reflection effect.
  • Alignment: Gets or sets the alignment of the reflection effect.
  • BlurRadius: Gets or sets the blur radius of the reflection effect. The blur radius is specified in points (1/72 inch).
  • VerticalSkewAngle: Gets or sets the vertical skew angle of the reflection effect. The skew angle is specified in degrees.
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-reflection-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()
{
    ReflectionEffect = new Reflection()
    {
        Alignment = RectangleAlignmentValues.BottomLeft,
        BlurRadius = 5,
        DirectionAngle = 90,
        DistanceFromText = 5,
        EndingOpacity = 100,
        EndPosition = 10,
        FadeDirectionAngle = 90,
        HorizontalScalingFactor = 100,
        HorizontalSkewAngle = 0,
        SchemeColor = IronWord.Models.Color.Gold,
        StartingOpacity = 0,
        StartPosition = 0,
        VerticalScalingFactor = -100,
        VerticalSkewAngle = 0,
    },
};

// Add text with style
doc.AddText("Customized reflection").Style = textStyle;

// Export new Word document
doc.SaveAs("customizedReflectionEffect.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 {
	.ReflectionEffect = New Reflection() With {
		.Alignment = RectangleAlignmentValues.BottomLeft,
		.BlurRadius = 5,
		.DirectionAngle = 90,
		.DistanceFromText = 5,
		.EndingOpacity = 100,
		.EndPosition = 10,
		.FadeDirectionAngle = 90,
		.HorizontalScalingFactor = 100,
		.HorizontalSkewAngle = 0,
		.SchemeColor = IronWord.Models.Color.Gold,
		.StartingOpacity = 0,
		.StartPosition = 0,
		.VerticalScalingFactor = -100,
		.VerticalSkewAngle = 0
	}
}

' Add text with style
doc.AddText("Customized reflection").Style = textStyle

' Export new Word document
doc.SaveAs("customizedReflectionEffect.docx")
$vbLabelText   $csharpLabel
Customized reflection effect

Questions Fréquemment Posées

Comment puis-je ajouter un effet de réflexion au texte dans un document Word en utilisant C# ?

Vous pouvez ajouter un effet de réflexion au texte dans un document Word en utilisant C# en téléchargeant la bibliothèque IronWord. Commencez par créer un objet `TextStyle`, remplissez sa propriété `ReflectionEffect` avec un objet `Reflection`, et personnalisez les propriétés à votre convenance. Enfin, exportez le document Word avec l'effet de réflexion appliqué.

Quelles propriétés peuvent être ajustées pour un effet de réflexion dans IronWord?

Dans IronWord, vous pouvez ajuster des propriétés telles que `SchemeColor`, `HorizontalSkewAngle`, `HorizontalScalingFactor`, `DistanceFromText`, `DirectionAngle`, `FadeDirectionAngle`, `EndPosition`, `StartPosition`, `EndingOpacity`, `VerticalScalingFactor`, `StartingOpacity`, `Alignment`, `BlurRadius`, et `VerticalSkewAngle` pour personnaliser l'effet de réflexion.

Comment personnaliser la distance de l'effet de réflexion par rapport au texte ?

Dans IronWord, utilisez la propriété `DistanceFromText` pour définir la distance de l'effet de réflexion par rapport au texte. Cette distance est spécifiée en points (1/72 pouce), vous permettant de contrôler la distance de la réflexion par rapport au texte original.

Puis-je ajuster l'opacité de l'effet de réflexion dans IronWord ?

Oui, l'opacité de l'effet de réflexion dans IronWord peut être personnalisée en utilisant les propriétés `StartingOpacity` et `EndingOpacity`. Cela vous permet de définir comment la réflexion commence et se termine en termes de transparence, vous donnant le contrôle de sa présence visuelle.

Quel est le but de la `HorizontalSkewAngle` dans un effet de réflexion ?

La propriété `HorizontalSkewAngle` dans IronWord définit l'angle d'inclinaison horizontal de l'effet de réflexion. Spécifiée en degrés, cette propriété altère l'apparence de la réflexion en la déformant horizontalement.

Comment commencer à ajouter un effet de réflexion au texte en C# ?

Commencez par télécharger la bibliothèque IronWord. Créez un objet `TextStyle` et remplissez la propriété `ReflectionEffect` avec un objet `Reflection`. Utilisez les propriétés disponibles pour personnaliser l'effet et l'appliquer à votre texte.

Est-il possible d'ajuster le flou d'un effet de réflexion dans IronWord ?

Oui, vous pouvez ajuster le flou d'un effet de réflexion dans IronWord en définissant la propriété `BlurRadius`. Cette valeur est spécifiée en points (1/72 pouce), vous permettant de contrôler la douceur de la réflexion.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 25,807 | Version : 2025.11 vient de sortir