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()
{
    ShadowEffect = Shadow.OuterShadow1,
};

// 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("shadowEffect.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 {
    .ShadowEffect = Shadow.OuterShadow1
}

' 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("shadowEffect.docx")
NuGet Download
PM > Install-Package IronWord
添加阴影效果

添加阴影效果

为文本添加阴影效果

阴影效果通过在字符后方创建阴影偏移,为文本增加深度和立体感。 IronWord通过Shadow类提供预定义的阴影预设,提供各种阴影样式,可以快速应用,无需手动配置。

要添加阴影效果,请创建一个Shadow.OuterShadow1。 来自Shadow类的这些静态命名实例提供专业设计的阴影配置,适合的模糊、距离和角度设置。 外阴影变体将阴影向外投射,使文本产生凸起的效果。

一旦文本样式配置好所需的阴影效果,创建一个包含run。 使用document中。 这种方法遵循IronWord的document层次结构,并确保阴影效果正确应用到输出文件。

代码解释

只需几行代码,即可为 Word 文档中的文本添加阴影效果。 为完整性考虑,先初始化一个新的doc。 然后,创建并配置一个TextEffect属性,来加入阴影效果。

为了添加带有阴影效果的样式化文本,先创建一个Paragraph,然后再创建一个包含"Hello World"的Run对象。 将配置好的Run,应用阴影效果。 通过Paragraph添加到文档中。 这遵循文档的层次结构:DocumentParagraphRunTextContent。 最后,导出 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 天试用密钥
无需信用卡或创建账户