# Text Effect

DsWord is a Document Solutions product that offers a high performance library to create, load, modify, and save Word documents programmatically.

## Content

DsWord lets you set following effects to your text:

* Fill and Line Effects
* Shadow Effects

## Fill and Line Effect

DsWord lets you apply effects to your fonts by using the [Font.Fill](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Font.Fill.html) and [Font.Line](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Font.Line.html) properties. You can set both Fill and Line properties to **NoFill**, **Solid** or **Gradient** type only through Type property. The Type property accepts values from **FillType** enumeration.
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/font-fill-and-line.png)
**Font.Fill** and **Font.Color** properties are interdependent. Following table demonstrates their dependency on each other:

| Font.Fill | Font.Color |
| --------- | ---------- |
| Not specified | **Font.Fill** takes the value from **Font.Color** as Solid type. |
| Any of Font.Fill properties are specified. | **Font.Color** uses **Font.Fill.SolidFill** properties. |
| **Font.Fill** type is specified as **Gradient.** | **Font.Fill** and **Font.Color** are independent of each other. DsWord uses Font.Fill to render the font. |

In addition, you can also set the Font.Line property to give your fonts an outline effect. Font.Line and Font.Color are independent of each other.

```CS
// Specify gradient fill for the font:
 var fill = style.Font.Fill;
 fill.Type = FillType.Gradient;
 var gradient = fill.GradientFill;
 gradient.Angle = 64;
 gradient.Stops[0].Color.RGB = Color.LightSeaGreen;
 gradient.Stops[1].Color.RGB = Color.Orange;
 
 // Specify the outline for the font:
 var line = style.Font.Line;
 line.Width = 1;
 fill = line.Fill;
 fill.Type = FillType.Solid;
 fill.SolidFill.RGB = Color.Blue;
 
 // Add sample text with the new style:
 doc.Body.Paragraphs.Add("Font Fill and Line styles.", style);
```

## Shadow Effect

The shadow effect adds additional depth to your text. DsWord allows you to apply shadow effects to text using built-in shadow effects and using custom shadow effects. To apply built-in shadow effect to a text, you can use [ApplyBuiltInShadow](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.TextEffects.ApplyBuiltInShadow.html) method of the [TextEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.TextEffects.html) class that accepts [BuiltInShadowId](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BuiltInShadowId.html) enum as its parameter. However, for applying custom shadow effect to a text, you can use **OuterShadow** type of the **TextEffects** class and set its properties.
The code below shows how to apply built-in shadow to text using the ApplyBuiltInShadow method:

```csharp
// apply top right offset shadow effect to the text
style.Font.Effects.ApplyBuiltInShadow(BuiltInShadowId.OffsetTopRight);
doc.Body.Paragraphs.Add("Font Shadow", style);
```

The code below shows how to apply custom shadow to a text using the OuterShadow type:

```csharp
// apply top right offset shadow effect to the text
OuterShadow shadow = style.Font.Effects.Shadow;
shadow.Alignment = RectangleAlignment.BottomLeft;
shadow.Angle = 315f;
shadow.Blur = 4f;
shadow.Distance = 3f;
shadow.ScaleX = 100f;
shadow.ScaleY = 100f;
shadow.SkewX = 0f;
shadow.SkewY = 0f;
shadow.Color.RGB = Color.Black;
shadow.Color.Transparency = 0.6f;
doc.Body.Paragraphs.Add("Font Shadow", style);
```

## Reflection Effect

DsWord allows you to apply reflection effects to text using built-in reflection effects and custom reflection effects. To apply built-in reflection effect to a text, you can use [ApplyBuiltInReflection](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.TextEffects.ApplyBuiltInReflection.html) method of the **TextEffects** class that accepts [BuiltInReflectionId](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BuiltInReflectionId.html) enum as its parameter. However, for applying custom reflection effect to a text, you can use **Reflection** type of the TextEffects class and set its properties.
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/reflection-builtin-text.png)
The code below shows how to apply built-in reflection to text using the ApplyBuiltInReflection method:

```csharp
// apply top half touching reflection effect to the text
style1.Font.Effects.ApplyBuiltInReflection(BuiltInReflectionId.HalfTouching);
doc.Body.Paragraphs.Add("Font Reflection.", style1);
```

The code below show how to apply custom reflection to text using the Reflection type:

```csharp
// Custom text reflection:
var style0 = doc.Styles.Add("style0", StyleType.Paragraph);
style0.Font.Size = 48;
// apply top half touching reflection effect to the text
Reflection reflection = style0.Font.Effects.Reflection;
reflection.Distance = 0f;
reflection.Angle = 90f;
reflection.Blur = 0.5f;
reflection.Alignment = RectangleAlignment.BottomLeft;
reflection.ScaleX = 100f;
reflection.ScaleY = -100f;
reflection.SkewX = 0f;
reflection.SkewY = 0f;
reflection.StartOpacity = 60f;
reflection.EndOpacity = 0.9f;
reflection.StartOpacityPosition = 0f;
reflection.EndOpacityPosition = 58f;
reflection.OpacityAngle = 90f;
doc.Body.Paragraphs.Add("Font Reflection.", style0);
```

To view the code in action, see [Reflection Effect demo](https://developer.mescius.com/documents-api-word/demos/features/effects/reflection-effect/word-cs) sample.

## Glow Format

DsWord allows you to apply glow effects to text using built-in glow effects and custom glow effects. To apply built-in glow effect to a text, you can use [ApplyBuiltInGlow](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.TextEffects.ApplyBuiltInGlow.html) method of the **TextEffects** class that accepts [BuiltInGlowId](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BuiltInGlowId.html) enum as its parameter. However, for applying custom glow effect to a text, you can use **Glow** type of the TextEffects class and set its properties.
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/font-glow-builtin.png)
The code below shows how to apply built-in glow to a shape using the ApplyBuiltInGlow method:

```csharp
// apply 5 point accent 5 glow effect to the text
style.Font.Effects.ApplyBuiltInGlow(BuiltInGlowId.Radius5Accent5);
doc.Body.Paragraphs.Add("Font Glow", style);
```

The code below shows how to apply custom glow effect to a shape:

```csharp
// apply 5 point accent 6 glow effect to the text
Glow glow = style.Font.Effects.Glow;
glow.Radius = 5f;
glow.Color.ThemeColor = ThemeColorId.Accent6;
glow.Color.Transparency = 0.6f;
doc.Body.Paragraphs.Add("Font Glow", style);
```

To view the code in action, see [Glow Effect Demo](https://developer.mescius.com/documents-api-word/demos/features/effects/glow-effect/word-cs) sample.

## 3D Effect

The 3D effects refer to the effects applied in three spatial dimensions: width, height, and depth. The 3D effects give the text a unique and artistic look. For applying 3D effects, DsWord provides the [ThreeDFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ThreeDFormat.html) and [ThreeDScene](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ThreeDScene.html) classes and the [ApplyEffectsPreset](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Font.ApplyEffectsPreset.html) method. The ApplyEffectsPreset method allows a user to add preset 3D effects. However, the ThreeDFormat and ThreeDScene classes allow a user to add custom 3D effects. DsWord also provides an [IFixedFormattingBag](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.IFixedFormattingBag.html) interface for all text effects and allows a user to understand and control whether the text has a direct effect or is inherited from its parent.

| **Preset 3D Effect** | **Custom 3D Effect** |
| ---------------- | ---------------- |
| ![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/text-preset-3d-effect.png) | ![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/text-3d-effect.png) |

Refer to the following example code to add a preset 3D effect to the text:

```csharp
// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Add a paragraph to the document.
Paragraph paragraph = doc.Body.Paragraphs.Add();
Run run = paragraph.GetRange().Runs.Add("3D Effects");

// Set font size.
run.Font.Size = 72f;

// Apply preset text 3D effect.
run.Font.ApplyEffectsPreset(FontEffectsPreset.Preset5);

// Save the Word document.
doc.Save("Preset3DEffects.docx");
```

Refer to the following example code to add a custom 3D effect to the text:

```csharp
// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Add a paragraph to the document.
Paragraph paragraph = doc.Body.Paragraphs.Add();
Run run = paragraph.GetRange().Runs.Add("3D Effects");

// Set text style.
GrapeCity.Documents.Word.Font font = run.Font;
font.Size = 72f;
font.Bold = true;
font.Color.ThemeColor = ThemeColorId.Accent3;
font.Line.Fill.Type = FillType.NoFill;

// Apply 3D effect.
ThreeDFormat threeD = font.Effects.ThreeDFormat;
threeD.Material = MaterialType.Matte;
threeD.Depth.Width = 4.5f;
threeD.TopBevel.Type = BevelType.Angle;
threeD.TopBevel.Width = 5f;
threeD.TopBevel.Height = 1f;

// Save the Word document.
doc.Save("3DEffects.docx");
```

**Limitation**
DsWord does not support export of font fill and line, font shadow, reflection, and glow effects to PDF and images.