添加陰影效果

在文字上實現陰影效果

陰影效果透過在字元後方產生陰影偏移,為文字增添深度與立體感。 IronWord provides predefined shadow presets through the Shadow class, offering various shadow styles that can be applied quickly without manual configuration.

To add a shadow effect, create a TextStyle and configure its TextEffect property with a shadow preset such as Shadow.OuterShadow1. These static named instances from the Shadow class provide professionally designed shadow configurations with appropriate blur, distance, and angle settings. 外陰影變體會將陰影向文字外側投射,營造出浮雕般的視覺效果。

Once the text style is configured with the desired shadow effect, create a Run object containing TextContent and assign the style to the run. Add the styled run to a paragraph using AddChild, then include the paragraph in the document. 此方法遵循 IronWord 的文件層級結構,並確保陰影效果能正確套用至輸出檔案。

程式碼解釋

只需幾行程式碼,即可為 Word 文件中的文字新增陰影效果。 For completeness, let's first initialize a new WordDocument instance called doc. Then, a TextStyle object is created and configured to incorporate a shadow effect by assigning the Shadow.OuterShadow1 static named instance to the TextEffect property.

To add the styled text with the shadow effect, a Paragraph is created, then a Run object is created containing TextContent with "Hello World". The configured textStyle is assigned to the Run, applying the shadow effect. The Run is added to the Paragraph using AddChild, and the Paragraph is added to the document. 此文件遵循以下層級結構:文件 → 段落 → 執行 → 文字內容。 最後,匯出 Word 文件。

更多範例和演示,請參閱以下文章:如何為文字添加陰影效果

透過 IronWord 教學探索文件元素。

準備好開始了嗎?
Nuget 下載 36,374 | 版本: 2026.3 剛剛發布
Still Scrolling Icon

還在捲動嗎?

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