添加發光效果
為文字添加發光效果
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 文件將被匯出為新檔案。

