新增反射效果

創建具有反射效果的文字

反射效果會在文字下方添加鏡像影像,營造出精緻現代的外觀。 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 下載 35,581 | 版本: 2026.3 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想要快速證明? PM > Install-Package IronWord
執行範例 觀看您的資料變成 Word doc。