新增發光效果

為文字添加發光效果

Applying a glow effect to text in IronWord is accomplished by configuring the TextEffect property of a TextStyle object. 發光效果會在文字周圍建立發光邊框,可透過自訂顏色和半徑屬性來控制視覺外觀。

To create a glow effect, instantiate a TextStyle and assign a TextEffect object with a configured Glow instance. The Glow object accepts properties like GlowColor to specify the color of the glow and GlowRadius to control the spread of the effect. 半徑值越高,產生的光暈越分散;半徑值越低,產生的光暈越集中。

After configuring the text style, create a Run object containing the desired TextContent and assign the configured style to the Run. Use AddChild to add the styled run to a paragraph, then add the paragraph to the document. 這遵循文件層次結構:文件 → 段落 → 執行 → 文字內容。

程式碼解釋

上面的程式碼片段示範如何建立一個新的 Word 文件並套用帶有發光效果的文字樣式。 First, a new Word document is instantiated and stored in the variable doc. Then, a new TextStyle object named textStyle is created. This text style is configured to include a glow effect by initializing a TextEffect object with specific settings.

To add the styled text with the glow effect, a Paragraph is created, then a Run object is created containing TextContent with "Hello World". The textStyle is assigned to the Run, which applies the glow effect. The Run is added to the Paragraph using AddChild, and finally the Paragraph is added to the document. 這種多步驟方法遵循文件層次結構:文件 → 段落 → 執行 → 文字內容。 最後,Word 文件被匯出為新文件。

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

了解更多關於IronWord文檔元素的信息

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

還在捲動嗎?

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