添加辉光效果

为文本添加发光效果

Applying a glow effect to text in IronWord is accomplished by configuring the TextEffect property of a TextStyle object. 发光效果会在文本周围创建发光边框,可通过自定义颜色和半径属性来控制视觉外观。

To create a glow effect, instantiate a TextStyle and assign a TextEffect object with a configured Glow instance. The Glow object accepts properties like GlowColor to specify the color of the glow and GlowRadius to control the spread of the effect. 半径值越高,产生的光晕越分散;半径值越低,产生的光晕越集中。

After configuring the text style, create a Run object containing the desired TextContent and assign the configured style to the Run. Use AddChild to add the styled run to a paragraph, then add the paragraph to the document. 这遵循文档层次结构:文档 → 段落 → 运行 → 文本内容。

代码解释

上面的代码片段演示了如何创建一个新的 Word 文档并应用带有发光效果的文本样式。 First, a new Word document is instantiated and stored in the variable doc. Then, a new TextStyle object named textStyle is created. This text style is configured to include a glow effect by initializing a TextEffect object with specific settings.

To add the styled text with the glow effect, a Paragraph is created, then a Run object is created containing TextContent with "Hello World". The textStyle is assigned to the Run, which applies the glow effect. The Run is added to the Paragraph using AddChild, and finally the Paragraph is added to the document. 这种多步骤方法遵循文档层次结构:文档 → 段落 → 运行 → 文本内容。 最后,Word 文档被导出为一个新文件。

更多示例和演示,请参阅以下文章:如何为文本添加发光效果

了解更多关于 IronWord 文档元素的信息

准备开始了吗?
Nuget 下载 36,374 | 版本: 2026.3 刚刚发布
Still Scrolling Icon

还在滚动吗?

想快速获得证据? PM > Install-Package IronWord
运行示例 观看您的数据变成 Word 文档。