IronWord 操作指南 文本上的陰影效果 How to Add Shadow Effect to Text Curtis Chau 更新日期:6月 9, 2025 Download IronWord NuGet 下載 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English The Shadow Effect on text is a visual enhancement technique used to create depth and distinction for text elements. When applied, it introduces a duplicated version of the text behind the original, slightly offset to give the appearance of a shadow. This secondary text, known as the shadow, can be adjusted in several ways to achieve different visual effects. Quickstart: Add a Preset Shadow Effect in One Line Here’s how to enhance your Word document text with a shadow using IronWord—just one line to define style and shadow, plus save. Ideal for devs who want results fast with minimal setup. Get started making PDFs with NuGet now: Install IronWord with NuGet Package Manager PM > Install-Package IronWord Copy and run this code snippet. new IronWord.WordDocument().AddText("Shadow!").Style = new IronWord.Models.TextStyle { TextEffect = new IronWord.Models.TextEffect { ShadowEffect = IronWord.Models.Shadow.OuterShadow1 } }; Deploy to test on your live environment Start using IronWord in your project today with a free trial Free 30 day Trial Minimal Workflow (5 steps) Download a C# library to add a shadow effect to text Apply the text effect to either newly created or existing text Apply a preset shadow effect using the static named instance of the Shadow class Configure the Shadow properties to achieve a customized shadow Export the edited Word document as a new file Add Shadow Effect To specify the shadow effect for the text, create the TextStyle object and populate the ShadowEffect property with a Shadow object. Finally, add new text with the style by assigning the TextStyle object to the TextEffect property. :path=/static-assets/word/content-code-examples/how-to/text-effect-shadow-effect.cs using IronWord; using IronWord.Models; // Create new Word document WordDocument doc = new WordDocument(); // Create and configure text style TextStyle textStyle = new TextStyle(); textStyle.TextEffect = new TextEffect() { ShadowEffect = Shadow.OuterShadow1, }; // Add text with style doc.AddText("Hello World").Style = textStyle; // Export new Word document doc.SaveAs("shadowEffect.docx"); Imports IronWord Imports IronWord.Models ' Create new Word document Private doc As New WordDocument() ' Create and configure text style Private textStyle As New TextStyle() textStyle.TextEffect = New TextEffect() With {.ShadowEffect = Shadow.OuterShadow1} ' Add text with style doc.AddText("Hello World").Style = textStyle ' Export new Word document doc.SaveAs("shadowEffect.docx") $vbLabelText $csharpLabel Shadow Effect Properties Besides assigning a predefined shadow value, all of the shadow effect's properties can be configured. This provides a very flexible option to customize the shadow effect in any way possible. Please see the properties and their descriptions below: Alignment: Gets or sets the alignment of the shadow. BlurRadius: Gets or sets the blur radius of the shadow effect. The blur radius is specified in points (1/72 inch). DirectionAngle: Gets or sets the direction angle of the shadow effect. The direction angle is specified in degrees. DistanceFromText: Gets or sets the distance of the shadow effect from the text or object. The distance is specified in points (1/72 inch). HorizontalScalingFactor: Gets or sets the horizontal scaling factor of the shadow effect. HorizontalSkewAngle: Gets or sets the horizontal skew angle of the shadow effect. The skew angle is specified in degrees. SchemeColor: Gets or sets the scheme color of the shadow effect. VerticalScalingFactor: Gets or sets the vertical scaling factor of the shadow effect. VerticalSkewAngle: Gets or sets the vertical skew angle of the shadow effect. The skew angle is specified in degrees. :path=/static-assets/word/content-code-examples/how-to/text-effect-customized-shadow-effect.cs using IronWord; using IronWord.Models; using IronWord.Models.Enums; // Create new Word document WordDocument doc = new WordDocument(); // Create and configure text style TextStyle textStyle = new TextStyle(); textStyle.TextEffect = new TextEffect() { ShadowEffect = new Shadow() { Alignment = RectangleAlignmentValues.BottomLeft, BlurRadius = 5, DirectionAngle = 45, DistanceFromText = 3, HorizontalScalingFactor = 100, VerticalScalingFactor = 100, HorizontalSkewAngle = 0, SchemeColor = IronWord.Models.Color.Aqua, VerticalSkewAngle = 0, }, }; // Add text with style doc.AddText("Customized shadow").Style = textStyle; // Export new Word document doc.SaveAs("customizedShadowEffect.docx"); Imports IronWord Imports IronWord.Models Imports IronWord.Models.Enums ' Create new Word document Private doc As New WordDocument() ' Create and configure text style Private textStyle As New TextStyle() textStyle.TextEffect = New TextEffect() With { .ShadowEffect = New Shadow() With { .Alignment = RectangleAlignmentValues.BottomLeft, .BlurRadius = 5, .DirectionAngle = 45, .DistanceFromText = 3, .HorizontalScalingFactor = 100, .VerticalScalingFactor = 100, .HorizontalSkewAngle = 0, .SchemeColor = IronWord.Models.Color.Aqua, .VerticalSkewAngle = 0 } } ' Add text with style doc.AddText("Customized shadow").Style = textStyle ' Export new Word document doc.SaveAs("customizedShadowEffect.docx") $vbLabelText $csharpLabel 常見問題解答 如何在 C# 中為文字添加陰影效果? 您可以通過使用 IronWord 函式庫在 C# 中為文字添加陰影效果。首先下載庫,然後使用 Shadow 類應用陰影效果。根據需要配置屬性,並導出應用了效果的文檔。 IronWord 中陰影效果的可自訂屬性有哪些? IronWord 允許您自訂陰影效果的多個屬性,包括 Alignment、BlurRadius、DirectionAngle、DistanceFromText、HorizontalScalingFactor、HorizontalSkewAngle、SchemeColor、VerticalScalingFactor 和 VerticalSkewAngle。 如何使用 IronWord 應用預設陰影效果? 要使用 IronWord 應用預設陰影效果,請使用 Shadow 類的靜態命名實例,並根據需要配置其屬性。 我可以在 Word 文件中的現有文字上添加陰影效果嗎? 是的,您可以通過創建 TextStyle 對象並將 ShadowEffect 屬性填充為 Shadow 對象來使用 IronWord 在 Word 文件中的新創建和現有文字上應用陰影效果。 陰影效果中 BlurRadius 屬性的作用是什麼? BlurRadius 屬性指定陰影效果的模糊半徑(以點為單位,1/72 英寸),從而確定陰影的柔和或銳利程度。 如何在 Word 文檔中控制陰影效果的方向? 要控制 IronWord 中陰影效果的方向,請設置度數指定的 DirectionAngle 屬性,使陰影按所需方向轉向。 是否可以將陰影與文字對齊不同的方向? 是的,IronWord 的 Alignment 屬性允許您設置陰影相對於文字的對齊方式,提供陰影如何定位的靈活性。 如何設置陰影效果的顏色以匹配文件主題? 使用 IronWord 中的 SchemeColor 屬性設置陰影效果的配色方案,使陰影與文檔的整體設計主題匹配。 陰影效果中的 DistanceFromText 屬性控制什麼? DistanceFromText 屬性控制文本或對象與陰影之間的距離,以點為單位(1/72 英寸),影響陰影與文字的距離。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 25,807 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:25,807 查看許可證