IRONSOFTWAREHOME
新增發光效果
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()
{
    GlowEffect = new Glow()
    {
        GlowColor = IronWord.Models.Color.Aqua,
        GlowRadius = 10,
    },
};

// Create paragraph
Paragraph paragraph = new Paragraph();

// Create run with text and style
Run textRun = new Run(new TextContent("Hello World"));
textRun.Style = textStyle;

// Add run to paragraph
paragraph.AddChild(textRun);

// Add paragraph to document
doc.AddParagraph(paragraph);

// Export new Word document
doc.SaveAs("glowEffect.docx");
Imports IronWord
Imports IronWord.Models

' Create new Word document
Dim doc As New WordDocument()

' Create and configure text style
Dim textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
    .GlowEffect = New Glow() With {
        .GlowColor = IronWord.Models.Color.Aqua,
        .GlowRadius = 10
    }
}

' Create paragraph
Dim paragraph As New Paragraph()

' Create run with text and style
Dim textRun As New Run(New TextContent("Hello World"))
textRun.Style = textStyle

' Add run to paragraph
paragraph.AddChild(textRun)

' Add paragraph to document
doc.AddParagraph(paragraph)

' Export new Word document
doc.SaveAs("glowEffect.docx")
NuGet Download
PM > Install-Package IronWord
新增發光效果

新增發光效果

為文字新增發光效果

在IronWord中對文字應用發光效果是透過配置TextStyle物件來實現的。 發光效果會在文字周圍建立一個發亮的邊緣,並可以自定義顏色和半徑屬性來控制視覺外觀。

要建立發光效果,需實例化一個TextEffect物件。 GlowRadius來控制效果的擴散。 較高的半徑值會產生更擴散的發光,而較低的值則會在文字周圍建立更緊密的光暈。

在配置好文字樣式之後,建立一個包含所需Run。 使用AddChild將樣式化的執行加入段落中,然後將段落加入文件中。 這遵循文件層級結構:Document → Paragraph → Run → TextContent。

程式碼解析

上述程式碼片段展示了如何建立一個新的Word文件並應用具有發光效果的文字樣式。 首先,實例化一個新的Word文件並儲存在變數doc中。 然後,建立一個名為TextStyle物件。 這種文字樣式配置為通過初始化一個具有特定設置的TextEffect物件來包括發光效果。

為了新增具有發光效果的樣式文字,先建立一個TextContent和"Hello World"的Run物件。 Run,應用了發光效果。 Paragraph加入文件中。 這種多步驟的方法遵循文件層級結構:Document → Paragraph → Run → TextContent。 最後,Word文件被匯出為新文件。

欲獲得更多範例和操作示範,請瀏覽以下文章:如何為文字新增發光效果

了解有關IronWord中文件元素的更多資訊
在 GitHub 上查看

準備開始了嗎?

Nuget Downloads 56,401版本:2026.9剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預約您的免費現場演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成以下表單或發郵件至sales@ironsoftware.com
您的詳細資訊將始終保持機密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立