添加漸變效果
上述代碼展示了如何對文本應用漸變效果。 首先,它創建一個新的 Word 文檔。 然後,它會創建一個TextStyle物件,並透過將GradientEffect屬性設置為Gradient.DefaultGray預設值來配置它以使用漸層效果。 此配置的 textStyle 隨後被應用到添加到文件中的文字 "Hello World"。 最後,新的 Word 文件被導出。 如需更多範例和示範,請瀏覽以下文章:如何為文字添加漸變效果。
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()
{
GradientEffect = Gradient.DefaultGray,
};
// Add text with style
doc.AddText("Hello World").Style = textStyle;
// Export new Word document
doc.SaveAs("gradientEffect.docx");Imports IronWord
Imports IronWord.Models
' Create new Word document
Private doc As New WordDocument()
' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {.GradientEffect = Gradient.DefaultGray}
' Add text with style
doc.AddText("Hello World").Style = textStyle
' Export new Word document
doc.SaveAs("gradientEffect.docx")Install-Package IronWord
上述代碼展示了如何對文本應用漸變效果。 首先,它創建一個新的 Word 文檔。 然後,它會創建一個TextStyle物件,並透過將GradientEffect屬性設置為Gradient.DefaultGray預設值來配置它以使用漸層效果。 此配置的 textStyle 隨後被應用到添加到文件中的文字 "Hello World"。 最後,新的 Word 文件被導出。 如需更多範例和示範,請瀏覽以下文章:如何為文字添加漸變效果。