How to Configure Print Settings in PDF Using C# | IronPrint

How to Add Gradient Text Effect in C#

To add gradient text effects in C#, use IronWord's TextStyle class with the GradientEffect property, which allows you to apply smooth color transitions across text characters using either built-in gradients or custom gradient stops.

A gradient effect on text involves applying a smooth transition of colors across the characters or background of text, creating a blend from one color to another or multiple colors. This effect adds depth, visual interest, and a dynamic appearance to the text, making it stand out and enhancing its aesthetic appearance. Gradient effects can be linear (colors transition in a straight line) or radial (colors transition from a central point outward). In document processing applications, gradient text effects are commonly used for headers, titles, promotional materials, and any content where visual emphasis is desired.

Quickstart: Add a Gradient Effect to Text with IronWord

Here’s a simple example showing how to use IronWord to apply a built-in gradient effect to text. Before running this code, ensure you have configured your license keys for IronWord.

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.

    var doc = new IronWord.WordDocument();
    doc.AddText("Test").Style = new IronWord.Models.TextStyle(){ TextEffect = new IronWord.Models.TextEffect(){ GradientEffect = IronWord.Models.Gradient.DefaultGray } };
    doc.SaveAs("out.docx");
  3. Deploy to test on your live environment

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

How Do I Add a Gradient Effect?

What Steps Are Required to Create Gradient Text?

To specify the gradient effect for the text, create the TextStyle object and populate the GradientEffect property with a Gradient object. Finally, add new text with the style by assigning the TextStyle object to the TextEffect property. This approach follows the same pattern used when creating empty presentations with IronWord’s sister library, IronPPT.

:path=/static-assets/word/content-code-examples/how-to/text-effect-gradient-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()
{
    GradientEffect = Gradient.DefaultGray,
};

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

// Export new Word document
doc.SaveAs("gradientEffect.docx");
$vbLabelText   $csharpLabel
Microsoft Word showing 'Hello World' text with gray gradient effect applied via Home tab font options

What Built-in Gradient Options Are Available?

IronWord provides several default gradient presets accessible through static properties of the Gradient class, including DefaultGray and other color combinations that can be applied instantly without custom configuration. These presets offer quick styling options similar to those found in Microsoft Word’s text formatting dialog. The built-in gradients work with standard document templates and maintain readability across different document formats.

When working with gradient effects in production environments, consider reviewing the licensing options to ensure your application has the appropriate coverage for your deployment scenarios.

What Properties Can I Customize for Gradient Effects?

How Do Gradient Stops Work?

The gradient effect provides adjustable attributes for various design needs. See the following list for detailed descriptions of each property:

GradientStop

  • Color: Gets or sets the scheme color of the gradient stop. Colors can be specified using IronWord’s predefined color constants or custom RGB values.
  • StopPoint: Gets or sets the position of the gradient stop. Values typically range from 0 to 100, representing percentage positions along the gradient path.

Gradient stops are points within a gradient where a specific color is defined. Multiple stops create smooth transitions between colors, and the spacing between stops determines how gradual or abrupt the color changes appear.

Gradient

  • StopPoints: Gets or sets the list of gradient stops defining the gradient fill. A minimum of two stops is required for a basic gradient.
  • LinearShadeScaled: Gets or sets a value indicating whether the linear shade is scaled. When true, the gradient adjusts to fit the text boundaries.
  • LinearShadeAngle: Gets or sets the angle of the linear shade. This property controls the direction of the gradient flow across the text.

For teams planning to expand their document processing capabilities, the upgrade options provide flexible paths to scale your implementation across multiple projects and developers.

How Can I Create Custom Gradient Effects?

Creating custom gradient effects allows for unique text styling that matches your brand or design requirements. The following example demonstrates how to build a two-color gradient with specific angle and scaling properties. For the latest features and improvements related to gradient effects, check the product changelog.

:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-gradient-effect.cs
using IronWord;
using IronWord.Models;
using System.Collections.Generic;

// Create new Word document
WordDocument doc = new WordDocument();

// Create gradient stops
GradientStop firstGradientStop = new GradientStop()
{
    Color = IronWord.Models.Color.Aqua,
    StopPoint = 1
};
GradientStop secondGradientStop = new GradientStop()
{
    Color = IronWord.Models.Color.OrangeRed,
    StopPoint = 10
};

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    GradientEffect = new Gradient()
    {
        StopPoints = new List<GradientStop> { firstGradientStop, secondGradientStop },
        LinearShadeAngle = 45,
        LinearShadeScaled = true,
    }
};

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

// Export new Word document
doc.SaveAs("customizedGradientEffect.docx");
$vbLabelText   $csharpLabel
Microsoft Word document showing 'Customized gradient' text with cyan-to-brown gradient color effect applied

What Angle Values Produce Different Effects?

LinearShadeAngle accepts values from 0 to 360 degrees, where 0° creates a horizontal gradient from left to right, 90° creates a vertical gradient from top to bottom, and 45° creates a diagonal gradient effect as shown in the example above. Common angle configurations include:

  • 0° (Horizontal Left-to-Right): Creates a side-to-side gradient, ideal for modern headings
  • 90° (Vertical Top-to-Bottom): Produces a top-down fade effect
  • 45° (Diagonal): Generates a corner-to-corner transition
  • 180° (Horizontal Right-to-Left): Reverses the standard horizontal gradient direction
  • 270° (Vertical Bottom-to-Top): Creates an upward gradient effect

When implementing gradient effects across multiple documents or templates, consider licensing extensions to ensure continuous access to updates and support.

Best Practices for Gradient Text Effects

When applying gradient effects to text in professional documents, consider these guidelines:

  1. Readability First: Ensure sufficient contrast between gradient colors and the document background
  2. Color Harmony: Choose colors that complement your document’s overall design scheme
  3. Subtlety in Business Documents: For formal documents, use muted gradients rather than bold color transitions
  4. Performance Considerations: Complex gradients with many stops may impact document rendering speed
  5. Cross-Platform Compatibility: Test gradient appearance across different Word viewers and PDF exports

Gradient effects work particularly well for document elements like chapter titles, section headers, and callout text where visual emphasis enhances the reader’s navigation experience.

Frequently Asked Questions

How do I add a gradient text effect in C#?

To add gradient text effects in C#, use IronWord's TextStyle class with the GradientEffect property. Create a TextStyle object, populate its GradientEffect property with a Gradient object, and assign this style to your text. IronWord allows you to apply smooth color transitions across text characters using either built-in gradients or custom gradient stops.

What built-in gradient options are available?

IronWord provides several default gradient presets accessible through static properties of the Gradient class, including DefaultGray and other color combinations. These presets can be applied instantly without custom configuration, offering quick styling options similar to those found in Microsoft Word's text formatting dialog.

Can I create custom gradient effects beyond the built-in options?

Yes, IronWord allows you to create custom gradient effects with custom gradient stops. While the built-in gradients like DefaultGray provide quick solutions, you can configure the GradientEffect properties to create your own color transitions and customize the text outline appearance.

What types of gradient effects can be applied to text?

IronWord supports gradient effects that create smooth transitions of colors across text characters. These can include linear gradients (colors transition in a straight line) or radial gradients (colors transition from a central point outward), adding depth and visual interest to headers, titles, and promotional materials.

How do I apply a gradient effect to existing text?

With IronWord, you can apply gradient effects to both newly created and existing text. Simply create a TextStyle object with the desired GradientEffect property and assign it to your text's Style property. The gradient will be applied when you save the document.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 29,064 | Version: 2025.12 just released