添加渐变效果
上述代码演示了如何给文本应用渐变效果。 首先,它创建一个新的Word文档。 然后,它创建一个TextStyle对象,并通过将Gradient.DefaultGray预设分配给GradientEffect属性来配置其使用渐变效果。 该配置的 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对象,并通过将Gradient.DefaultGray预设分配给GradientEffect属性来配置其使用渐变效果。 该配置的 textStyle 然后应用于添加到文档中的文字“Hello World”。 最后,新的 Word 文档被导出。 有关更多示例和演示,请导航到以下文章:如何为文本添加渐变效果。