添加文本轮廓

添加文本轮廓效果

文本轮廓效果通过在每个字符周围绘制边框来增强文本的可见性和样式。 这种效果对于创建醒目、引人注目的文本,或者确保文本出现在图像或彩色背景上时的可读性尤其有用。 IronWord provides the TextOutlineEffect class with preset configurations for quick implementation.

To apply a text outline, create a TextStyle object and configure its TextEffect property with TextOutlineEffect.DefaultEffect. 此预设提供了一个标准的轮廓配置,适用于大多数场景。 对于自定义轮廓,开发人员可以指定轮廓宽度、颜色和线条样式等属性,以实现特定的视觉效果。

After setting up the text style, create a Run containing the desired TextContent and assign the configured style to the run's Style property. Use AddChild to add the styled run to a paragraph, then add the paragraph to the document. 这种结构化的方法可以确保格式正确,并保持文档的完整性。

代码解释

使用 IronWord 为文本添加轮廓非常简单。 尽管文本轮廓很简单,但每个属性都可以进行调整以满足各种需求。 Once a Word document is imported, the textStyle is configured to include a text outline effect by assigning TextOutlineEffect.DefaultEffect to the TextOutlineEffect property of a new TextEffect instance.

To apply this effect to text, a Paragraph is created, then a Run object is created containing the desired TextContent. The configured textStyle is assigned to the Run, applying the text outline effect. The Run is added to the Paragraph using AddChild, and the Paragraph is added to the document. 这遵循文档层次结构:文档 → 段落 → 运行 → 文本内容。 最后,文档被导出。

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

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

还在滚动吗?

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