IronWord 操作指南 文字上的光暈效果 如何在 C# 中為文字添加發光效果 Curtis Chau 更新:2026年1月10日 下載 IronWord NuGet 下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 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天 ### 最小工作流程(5 個步驟) 下載用於添加文字光暈效果的 C# 庫 將文字效果應用於新創建或現有文字 配置發光對象並將其指派給文字效果對象 將其指派給TextEffect屬性 將編輯后的 Word 文件導出為新文件 如何在 C# 中為文字加入光暈效果? 若要為文字新增炫光效果,請先建立並設定 Glow 物件。然後建立一個包含此 Glow 物件的 TextEffect 物件。 最後,將 TextEffect 指定給文字的 TextEffect 屬性。 此方法可完全控制螢光外觀和強度。 為什麼要先建立 Glow 物件? 首先建立一個 Glow 物件,就可以在應用之前設定所有的 glow 屬性。 這將遵循關注點分離的原則,並改善程式碼的可維護性。 獨立定義 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"); } } Imports IronWord Imports IronWord.Models Imports System.Drawing Public Class TextGlowEffectExample Public Sub ApplyGlowEffect() ' Create a new Word document Dim doc As New WordDocument() ' Add a paragraph with text Dim paragraph As New Paragraph() Dim textRun As New Text("This text has a bright glow!") paragraph.AddTextRun(textRun) ' Initialize a new Glow object Dim glow As 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 Dim textEffect As 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") End Sub End Class $vbLabelText $csharpLabel 什麼是 Glow 效果屬性? 了解螢光效果的屬性,對於建立專業的外觀效果,在不壓迫內容的情況下增強文件的效果是非常重要的。 適當的授權可確保這些功能在生產環境中不受任何限制地運作。 哪些屬性控制 Glow 外觀? GlowRadius:設定光暈效果的半徑,單位為點(1/72 英吋)。 分值通常在 5 到 30 分之間。 較大的數值會產生更散漫、更分散的光線。 5-10 點的半徑可創造微妙的亮點; 20-30 點會產生戲劇性的光暈。 GlowColor:設定螢光效果顏色。 接受 System.Drawing.Color 值,包括用於透明度控制的 ARGB。 鮮豔的色彩(青色、黃色、洋紅色)可創造出活潑的效果; 深色提供微妙的強調。 如何使用 Alpha 透明度設定顏色值? 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"); } } Imports IronWord Imports IronWord.Models Imports System.Drawing Public Class AlphaTransparencyExample Public Sub DemonstrateAlphaValues() Dim doc As New WordDocument() ' Create multiple text samples with different alpha values Dim alphaValues As Integer() = {50, 100, 150, 200, 255} For Each alpha As Integer In alphaValues Dim para As New Paragraph() Dim text As New Text($"Alpha: {alpha} - Glow Effect Sample") ' Create glow with specific alpha transparency Dim glow As New Glow With { .GlowRadius = 12, .GlowColor = Color.FromArgb(alpha, 255, 215, 0) ' Gold with varying transparency } ' Apply the glow effect Dim effect As New TextEffect With {.GlowEffect = glow} text.Style = New TextStyle With { .TextEffect = effect, .FontSize = 24, .FontFamily = "Arial" } para.AddTextRun(text) doc.AddParagraph(para) Next doc.SaveAs("alpha-transparency-demo.docx") End Sub End Class $vbLabelText $csharpLabel Alpha 值指引: 50-100:非常微妙、幾乎看不見的水印式效果 100-150:柔和的光澤,商業文件的專業外觀 150-200:中等強度,平衡標頭和標題 200-255:強烈的光彩,宣傳材料的高影響力 有哪些炫光效果範例? Glow 效果接受 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"); } } Public Class RadiusExamples Public Sub CreateRadiusComparison() Dim doc As New WordDocument() ' Example 1: Subtle emphasis for inline text Dim p1 As New Paragraph() Dim subtleText As New Text("Important: This deadline cannot be extended.") subtleText.Style = New TextStyle With { .TextEffect = New TextEffect With { .GlowEffect = New Glow With { .GlowRadius = 6, .GlowColor = Color.FromArgb(180, 255, 0, 0) ' Soft red glow } } } p1.AddTextRun(subtleText) ' Example 2: Section header with medium glow Dim p2 As New Paragraph() Dim headerText As New Text("Chapter 1: Getting Started") headerText.Style = New TextStyle With { .FontSize = 28, .FontFamily = "Calibri", .TextEffect = New TextEffect With { .GlowEffect = New Glow With { .GlowRadius = 18, .GlowColor = Color.FromArgb(150, 0, 120, 215) ' Corporate blue } } } p2.AddTextRun(headerText) ' Example 3: Promotional text with large glow Dim p3 As New Paragraph() Dim promoText As New Text("SPECIAL OFFER - LIMITED TIME!") promoText.Style = New TextStyle With { .FontSize = 36, .Bold = True, .TextEffect = New TextEffect With { .GlowEffect = New Glow With { .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") End Sub End Class $vbLabelText $csharpLabel 光暈效果的常見顏色組合有哪些? 有效的顏色組合取決於文件目的和品牌。 專業文件使用微妙的藍色、灰色或 Alpha 值較低的品牌顏色。 行銷材料採用鮮豔的互補色或高對比的組合。 使用多個 Iron Software 產品時,請檢查 產品更新,以確保相容性。 常見的顏色組合: 1.Professional Blue:帶有淺藍色光彩的深藍色文字 (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 立即與工程團隊聊天 技術撰稿人 Curtis Chau 擁有電腦科學學士學位(卡爾頓大學),專長於前端開發,精通 Node.js、TypeScript、JavaScript 和 React。Curtis 對製作直覺且美觀的使用者介面充滿熱情,他喜歡使用現代化的架構,並製作結構良好且視覺上吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 也有濃厚的興趣,他喜歡探索整合硬體與軟體的創新方式。在空閒時間,他喜歡玩遊戲和建立 Discord bots,將他對技術的熱愛與創意結合。 準備好開始了嗎? Nuget 下載 32,629 | 版本: 2026.2 剛剛發布 免費 NuGet 下載 總下載量:32,629 查看許可證