IronWord 操作指南 文字上的光暈效果 如何在 C# 中為文字添加發光效果 柯蒂斯·週 更新:1月 10, 2026 下載 IronWord NuGet 下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 分享 分享到 X(Twitter) 在領英上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 發光效果會在文字周圍營造出一種發光的光暈。 這種視覺效果使文字看起來像是在發光,並帶有柔和的輪廓。在 C# 應用程式(尤其是 Word 文件)中,發光效果有助於突出顯示標題、正文標題和重要內容。 這種效果廣泛應用於簡報、行銷資料和需要視覺強調文字的專業文件。 快速入門:快速為文字元素套用發光效果 建立一個Glow對象,設定其GlowRadius和GlowColor ,將其嵌入到TextEffect中,並將其指派給文字樣式。 一行程式碼即可在 Word 文件中建立發光文字。 立即開始使用 NuGet 建立 PDF 檔案: 使用 NuGet 套件管理器安裝 IronWord PM > Install-Package IronWord 複製並運行這段程式碼。 someTextElement.Style.TextEffect = new IronWord.Models.TextEffect { GlowEffect = new IronWord.Models.Glow { GlowRadius = 8, GlowColor = System.Drawing.Color.FromArgb(180, 0, 128, 255) } }; 部署到您的生產環境進行測試 立即開始在您的專案中使用 IronWord,免費試用! 免費試用30天 IronWord入門指南 最簡工作流程(5個步驟) 下載一個用於為文字添加發光效果的 C# 庫 將文字效果套用至新建文字或現有文字。 Configure the `Glow` object and assign it to the `TextEffect` object Assign it to the `TextEffect` property 將編輯後的 Word 文件匯出為新文件 如何在C#中為文字添加發光效果? 若要為文字新增發光效果,請先建立並配置一個Glow物件。然後建立一個包含該Glow物件的TextEffect物件。 最後,將TextEffect賦值給文字的TextEffect屬性。 這種方法可以完全控制發光的外觀和強度。 為什麼先創建發光物體很重要? 首先建立Glow對象,可以在應用之前配置所有發光屬性。 這遵循關注點分離原則,提高了程式碼的可維護性。 獨立定義發光屬性可實現跨多個文字元素的重複使用,並可根據應用程式需求進行動態修改。 這種模式與其他 Iron Software 產品處理類似效果的方式一致,從而保持文件處理工作流程的一致性。 using IronWord; using IronWord.Models; using System.Drawing; public class TextGlowEffectExample { public void ApplyGlowEffect() { // Create a new Word document WordDocument doc = new WordDocument(); // Add a paragraph with text Paragraph paragraph = new Paragraph(); Text textRun = new Text("This text has a bright glow!"); paragraph.AddTextRun(textRun); // Initialize a new Glow object Glow glow = new Glow(); // Set the properties for the glow effect glow.GlowRadius = 15; // Radius of the glow effect in points glow.GlowColor = Color.FromArgb(200, 0, 255, 255); // Semi-transparent cyan // Create a TextEffect object and assign the glow effect to it TextEffect textEffect = new TextEffect(); textEffect.GlowEffect = glow; // Apply the TextEffect to the text textRun.Style = new TextStyle(); textRun.Style.TextEffect = textEffect; // Add the paragraph to the document doc.AddParagraph(paragraph); // Save the document doc.SaveAs("glowing-text-example.docx"); } } using IronWord; using IronWord.Models; using System.Drawing; public class TextGlowEffectExample { public void ApplyGlowEffect() { // Create a new Word document WordDocument doc = new WordDocument(); // Add a paragraph with text Paragraph paragraph = new Paragraph(); Text textRun = new Text("This text has a bright glow!"); paragraph.AddTextRun(textRun); // Initialize a new Glow object Glow glow = new Glow(); // Set the properties for the glow effect glow.GlowRadius = 15; // Radius of the glow effect in points glow.GlowColor = Color.FromArgb(200, 0, 255, 255); // Semi-transparent cyan // Create a TextEffect object and assign the glow effect to it TextEffect textEffect = new TextEffect(); textEffect.GlowEffect = glow; // Apply the TextEffect to the text textRun.Style = new TextStyle(); textRun.Style.TextEffect = textEffect; // Add the paragraph to the document doc.AddParagraph(paragraph); // Save the document doc.SaveAs("glowing-text-example.docx"); } } $vbLabelText $csharpLabel 發光效果有哪些特性? 了解發光效果的特性對於創造專業美觀的效果至關重要,這些效果可以增強文件效果,而不會喧賓奪主。 適當的許可確保這些功能在生產環境中不受限制地運作。 哪些屬性控制發光外觀? GlowRadius :以點(1/72 英吋)為單位設定發光效果的半徑。 數值範圍通常在 5 到 30 分之間。 數值越大,產生的光暈就越彌散、越分散。 半徑 5-10 點的光圈可以創造出微妙的高光效果; 20-30分能產生強烈的光暈效果。 GlowColor :設定發光效果顏色。 接受System.Drawing.Color值,包括用於透明度控制的 ARGB 值。 鮮豔的顏色(青色、黃色、洋紅色)能營造出鮮豔的效果; 深色能起到微妙的強調作用。 如何設定帶有透明度的顏色值? Alpha 透明度可創造逼真的光暈效果,並與背景自然融合。 Alpha 值範圍從 0(透明)到 255(不透明)。 以下是一個展示不同 alpha 值的範例: using IronWord; using IronWord.Models; using System.Drawing; public class AlphaTransparencyExample { public void DemonstrateAlphaValues() { WordDocument doc = new WordDocument(); // Create multiple text samples with different alpha values int[] alphaValues = { 50, 100, 150, 200, 255 }; foreach (int alpha in alphaValues) { Paragraph para = new Paragraph(); Text text = new Text($"Alpha: {alpha} - Glow Effect Sample"); // Create glow with specific alpha transparency Glow glow = new Glow { GlowRadius = 12, GlowColor = Color.FromArgb(alpha, 255, 215, 0) // Gold with varying transparency }; // Apply the glow effect TextEffect effect = new TextEffect { GlowEffect = glow }; text.Style = new TextStyle { TextEffect = effect, FontSize = 24, FontFamily = "Arial" }; para.AddTextRun(text); doc.AddParagraph(para); } doc.SaveAs("alpha-transparency-demo.docx"); } } using IronWord; using IronWord.Models; using System.Drawing; public class AlphaTransparencyExample { public void DemonstrateAlphaValues() { WordDocument doc = new WordDocument(); // Create multiple text samples with different alpha values int[] alphaValues = { 50, 100, 150, 200, 255 }; foreach (int alpha in alphaValues) { Paragraph para = new Paragraph(); Text text = new Text($"Alpha: {alpha} - Glow Effect Sample"); // Create glow with specific alpha transparency Glow glow = new Glow { GlowRadius = 12, GlowColor = Color.FromArgb(alpha, 255, 215, 0) // Gold with varying transparency }; // Apply the glow effect TextEffect effect = new TextEffect { GlowEffect = glow }; text.Style = new TextStyle { TextEffect = effect, FontSize = 24, FontFamily = "Arial" }; para.AddTextRun(text); doc.AddParagraph(para); } doc.SaveAs("alpha-transparency-demo.docx"); } } $vbLabelText $csharpLabel Alpha值準則: 50-100 :非常細微、幾乎看不見的水印式效果 100-150 :柔和光澤,商務文件的專業外觀 150-200 :中等強度,標題和標頭的平衡性良好 200-255 :強光,高衝擊力,適用於宣傳資料 發光效果有哪些例子? 發光效果接受 ARGB 顏色值。 alpha 值控制不透明度。 這些範例展示了發光效果在各種文件環境中的實際應用。 在生產環境部署前配置正確的許可證密鑰。 何時應該使用不同的半徑值? 不同的半徑值用於不同的用途。 小半徑(5-10 點)可產生聚焦光暈,以微妙的方式強調術語或連結。 中等半徑(15-20 磅)適用於章節標題和正文標題,可以提供清晰的層次結構。 大半徑(25 點以上)適用於需要最大衝擊力的封面或宣傳標註。 以下是一個展示半徑應用實例的範例: public class RadiusExamples { public void CreateRadiusComparison() { WordDocument doc = new WordDocument(); // Example 1: Subtle emphasis for inline text Paragraph p1 = new Paragraph(); Text subtleText = new Text("Important: This deadline cannot be extended."); subtleText.Style = new TextStyle { TextEffect = new TextEffect { GlowEffect = new Glow { GlowRadius = 6, GlowColor = Color.FromArgb(180, 255, 0, 0) // Soft red glow } } }; p1.AddTextRun(subtleText); // Example 2: Section header with medium glow Paragraph p2 = new Paragraph(); Text headerText = new Text("Chapter 1: Getting Started"); headerText.Style = new TextStyle { FontSize = 28, FontFamily = "Calibri", TextEffect = new TextEffect { GlowEffect = new Glow { GlowRadius = 18, GlowColor = Color.FromArgb(150, 0, 120, 215) // Corporate blue } } }; p2.AddTextRun(headerText); // Example 3: Promotional text with large glow Paragraph p3 = new Paragraph(); Text promoText = new Text("SPECIAL OFFER - LIMITED TIME!"); promoText.Style = new TextStyle { FontSize = 36, Bold = true, TextEffect = new TextEffect { GlowEffect = new Glow { GlowRadius = 30, GlowColor = Color.FromArgb(220, 255, 255, 0) // Bright yellow } } }; p3.AddTextRun(promoText); doc.AddParagraph(p1); doc.AddParagraph(p2); doc.AddParagraph(p3); doc.SaveAs("radius-examples.docx"); } } public class RadiusExamples { public void CreateRadiusComparison() { WordDocument doc = new WordDocument(); // Example 1: Subtle emphasis for inline text Paragraph p1 = new Paragraph(); Text subtleText = new Text("Important: This deadline cannot be extended."); subtleText.Style = new TextStyle { TextEffect = new TextEffect { GlowEffect = new Glow { GlowRadius = 6, GlowColor = Color.FromArgb(180, 255, 0, 0) // Soft red glow } } }; p1.AddTextRun(subtleText); // Example 2: Section header with medium glow Paragraph p2 = new Paragraph(); Text headerText = new Text("Chapter 1: Getting Started"); headerText.Style = new TextStyle { FontSize = 28, FontFamily = "Calibri", TextEffect = new TextEffect { GlowEffect = new Glow { GlowRadius = 18, GlowColor = Color.FromArgb(150, 0, 120, 215) // Corporate blue } } }; p2.AddTextRun(headerText); // Example 3: Promotional text with large glow Paragraph p3 = new Paragraph(); Text promoText = new Text("SPECIAL OFFER - LIMITED TIME!"); promoText.Style = new TextStyle { FontSize = 36, Bold = true, TextEffect = new TextEffect { GlowEffect = new Glow { GlowRadius = 30, GlowColor = Color.FromArgb(220, 255, 255, 0) // Bright yellow } } }; p3.AddTextRun(promoText); doc.AddParagraph(p1); doc.AddParagraph(p2); doc.AddParagraph(p3); doc.SaveAs("radius-examples.docx"); } } $vbLabelText $csharpLabel 發光效果常用的顏色組合有哪些? 有效的色彩搭配取決於文件用途和品牌形象。 專業文件使用柔和的藍色、灰色或品牌顏色,並採用較低的透明度值。 行銷材料採用鮮豔的互補色或高對比的組合。 使用多個 Iron Software 產品時,請檢查產品更新以確保相容性。 常見顏色組合: 1.專業藍:深藍色文字,淺藍色光暈(RGB:100、150、255) 2.暖色調強調:深棕色文字帶有金色光暈(RGB:255、200、50) 3.高對比:黑色文字帶有白色/銀色光暈(RGB:220, 220, 220) 4.品牌顏色:公司顏色文字搭配互補光暈 5.季節主題:節日用綠色/紅色,萬聖節用橘色/黑色 發光效果應該增強可讀性,而不是阻礙可讀性。 在不同背景下測試組合,並遵循無障礙指南。 對於需要擴展支援的企業應用程序,請考慮購買許可擴展,以獲取持續更新和功能。 在擴展應用程式時,升級選項可以為不斷成長的團隊和不斷增長的需求提供靈活性。 常見問題解答 如何使用 C# 為 Word 文件中的文字加入螢光效果? 若要使用 IronWord 新增炫光效果,請使用您所需的半徑和顏色設定來建立一個 Glow 物件,然後將其嵌入 TextEffect 物件中,並將其指定給文字元素的 Style.TextEffect 屬性。這可以在一行內完成: someTextElement.Style.TextEffect = new IronWord.Models.TextEffect { GlowEffect = new IronWord.Models.Glow { GlowRadius = 8, GlowColor = System.Drawing.Color.FromArgb(180, 0, 128, 255) }; }}; 創建發光文本最少需要多少代碼? IronWord 只需一行程式碼,就能讓您在文字元素的 Style.TextEffect 屬性中,設定包含已設定 Glow 物件的新 TextEffect,以建立會發光的文字。這包括在單一語句中設定輝光半徑和顏色。 我可以自訂螢光效果的外觀嗎? 是的,IronWord 透過 Glow 物件屬性提供完全自訂的 Glow 效果。您可以調整 GlowRadius(以點為單位)來控制炫光的大小,並使用 System.Drawing.Color 設定 GlowColor,以 ARGB 值來精確控制顏色和透明度。 為什麼要建立獨立的 Glow 物件,而不是內嵌組態? 在 IronWord 中建立獨立的 Glow 物件,可遵循關注點分離原則,並改善程式碼的可維護性。此方法可讓您在多個文字元素中重複使用相同的 Glow 設定,並根據應用程式需求動態修改屬性,與其他 Iron Software 產品所使用的一致模式相匹配。 為文字套用螢光效果的主要步驟是什麼? IronWord 的工作流程包括 5 個步驟:1) 下載 IronWord C# 函式庫;2) 將文字效果套用至新文字或現有文字;3) 以半徑和顏色設定配置 Glow 物件;4) 將 Glow 指定至 TextEffect 物件的 GlowEffect 屬性;5) 將已編輯的 Word 文件匯出為新檔案。 哪些類型的文件可從文字光暈效果中獲益? IronWord 的光暈效果功能對於建立簡報、行銷資料和專業文件等需要視覺強調的文字特別有用。夜光光環效果有助於突出 Word 文件中的標題、標題和重要內容。 柯蒂斯·週 現在就和工程團隊聊天吧 技術撰稿人 Curtis Chau擁有卡爾頓大學電腦科學學士學位,專長於前端開發,精通Node.js、TypeScript、JavaScript和React。他熱衷於打造直覺美觀的使用者介面,喜歡使用現代框架,並擅長撰寫結構清晰、視覺效果出色的使用者手冊。除了開發工作之外,柯蒂斯對物聯網 (IoT) 也抱有濃厚的興趣,致力於探索硬體和軟體整合的創新方法。閒暇時,他喜歡玩遊戲和製作 Discord 機器人,將他對科技的熱愛與創造力結合。 準備好開始了嗎? Nuget 下載 29,594 | 版本: 2025.12 剛剛發布 免費下載 NuGet 總下載量: 29,594 查看許可證