添加反射效果

创建具有反射效果的文本

反射效果会在文字下方添加镜像图像,营造出精致现代的外观。 In IronWord, this effect is applied through the ReflectionEffect property of a TextEffect object, which can be customized or used with default settings.

To implement a reflection effect, create a TextStyle and configure its TextEffect property with a Reflection instance. The Reflection class supports default initialization, which applies standard reflection parameters suitable for most use cases. 对于自定义反射,可以调整距离、模糊和透明度等属性来微调外观。

After defining the text style, create a Run containing your TextContent and assign the configured style to the run. Use AddChild to add the run to a paragraph, maintaining the proper document hierarchy of Document → Paragraph → Run → TextContent. 最后,将该段落添加到文档中以应用反射效果。

代码解释

让我们创建一个新的 Word 文档,并向其中添加带有反射效果的文本。 Initially, a new WordDocument object named doc is created. A TextStyle object is then instantiated and configured to include a reflection effect by setting its TextEffect property to a new Reflection object.

To add the styled text with the reflection effect, a Paragraph is created, then a Run object is created containing TextContent with "Hello World". The TextStyle is assigned to the Run, applying the reflection 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 文档。