如何在 C# 中为文本添加发光效果

How to Add Glow Effect to Text

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

The glow effect on text is a visual effect that creates a glowing aura around the characters. This effect makes the text appear as if it is emitting light, creating a soft, luminous outline that can enhance readability and draw attention.

Quickstart: Apply Glow Effect to a Text Element Fast

Just instantiate a Glow object, set its radius and color, embed it in a TextEffect, and assign it to your text’s style. In one short line you’ll see glowing text in your Word document.

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.

    someTextElement.Style.TextEffect = new IronWord.Models.TextEffect { GlowEffect = new IronWord.Models.Glow { GlowRadius = 8, GlowColor = System.Drawing.Color.FromArgb(180, 0, 128, 255) } };
  3. Deploy to test on your live environment

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

Get Started with IronWord

今天在您的项目中使用 IronWord,免费试用。

第一步:
green arrow pointer

Add Glow Effect

To specify the glow effect for the text, you can start by creating and configuring the Glow object. Then, create the TextEffect object from this Glow object. Finally, assign the TextEffect to the TextEffect property of the text.

using IronWord; // Import the necessary library

public class TextGlowEffectExample
{
    public void ApplyGlowEffect()
    {
        // Initialize a new Glow object
        Glow glow = new Glow();

        // Set the properties for the glow effect
        glow.GlowRadius = 5; // Radius of the glow effect
        glow.GlowColor = System.Drawing.Color.FromArgb(128, 255, 0, 0); // ARGB value for the glow color

        // Create a TextEffect object and assign the glow effect to it
        TextEffect textEffect = new TextEffect();
        textEffect.Glow = glow;

        // Apply the TextEffect to the text
        // Example: someTextElement.TextEffect = textEffect;

        // Further code to export or display the document would go here
    }
}
using IronWord; // Import the necessary library

public class TextGlowEffectExample
{
    public void ApplyGlowEffect()
    {
        // Initialize a new Glow object
        Glow glow = new Glow();

        // Set the properties for the glow effect
        glow.GlowRadius = 5; // Radius of the glow effect
        glow.GlowColor = System.Drawing.Color.FromArgb(128, 255, 0, 0); // ARGB value for the glow color

        // Create a TextEffect object and assign the glow effect to it
        TextEffect textEffect = new TextEffect();
        textEffect.Glow = glow;

        // Apply the TextEffect to the text
        // Example: someTextElement.TextEffect = textEffect;

        // Further code to export or display the document would go here
    }
}
Imports IronWord ' Import the necessary library

Public Class TextGlowEffectExample
	Public Sub ApplyGlowEffect()
		' Initialize a new Glow object
		Dim glow As New Glow()

		' Set the properties for the glow effect
		glow.GlowRadius = 5 ' Radius of the glow effect
		glow.GlowColor = System.Drawing.Color.FromArgb(128, 255, 0, 0) ' ARGB value for the glow color

		' Create a TextEffect object and assign the glow effect to it
		Dim textEffect As New TextEffect()
		textEffect.Glow = glow

		' Apply the TextEffect to the text
		' Example: someTextElement.TextEffect = textEffect;

		' Further code to export or display the document would go here
	End Sub
End Class
$vbLabelText   $csharpLabel
Add glow effect

Glow Effect Properties

Below are all the glow effect properties and their descriptions:

  • GlowRadius: Gets or sets the radius of the glow effect. The glow radius is specified in points (1/72 inch).
  • GlowColor: Gets or sets the color of the glow effect.

Glow Effect Examples

Let's look at some more glow effect examples. The color of the glow effect can also accept ARGB values. The first value is alpha, which describes how opaque the color is.

Glow effect examples

常见问题解答

如何在Word文档中为文本添加光晕效果?

要为Word文档的文本添加光晕效果,请使用专为此目的设计的C#库。初始化一个Glow对象,配置其属性如GlowRadiusGlowColor,并将其分配给TextEffect对象。最后,将此TextEffect应用于您的文本并导出文档。

需要什么代码来使用C#为文本应用光晕效果?

您可以通过导入必要的库并创建具有所需属性的Glow对象来应用光晕效果。将此对象分配给TextEffect对象并应用于您的文本。

文本编辑中光晕效果的关键属性是什么?

光晕效果的关键属性是GlowRadius,它设置光晕的半径(以点为单位),以及GlowColor,它定义光晕的颜色。这些属性可以通过配置来定制光晕效果的外观。

光晕颜色可以使用ARGB值自定义吗?

是的,光晕颜色可以使用ARGB值自定义。ARGB中的Alpha值决定光晕的透明度,可以实现广泛的颜色定制。

在应用光晕效果后如何导出Word文档?

使用C#库应用光晕效果后,通过调用库提供的适当方法将编辑过的Word文档保存或显示为新文件。

是否可以对新文本和现有文本都应用光晕效果?

是的,您可以在Word文档中对新创建的和现有文本都应用光晕效果。这种灵活性允许增强文档中任何文本元素。

GlowRadius属性的用途是什么?

GlowRadius属性指定光晕效果的半径(以点为单位),帮助确定光晕从文本延伸的距离。半径是以点为单位定义的,其中1点等于1/72英寸。

在C#中配置光晕效果需要什么步骤?

要在C#中配置光晕效果,初始化一个Glow对象,设置其GlowRadiusGlowColor属性,并将其分配给TextEffect对象。将TextEffect应用于您的文本并导出文档以查看更改。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 25,807 | 版本: 2025.11 刚刚发布