Spire.Presentation for .NET支持图片、文字阴影效果。在 C#如何设置PPT图片阴影效果 一文中,介绍了图片阴影效果的实现方法,在本篇示例中将介绍设置PPT文字阴影效果的方法。
C#
//实例化Presentation类,获取第一张幻灯片
Presentation presentation = new Presentation();
ISlide slide = presentation.Slides[0];
//在幻灯片指定位置绘制指定大小的矩形形状,并设置填形状填充
IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(80, 40, 500,350));
shape.ShapeStyle.LineColor.Color = Color.White;
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
//绘制文本内容到形状,并设置文本格式
shape.AppendTextFrame("如何通过使用Spire.Presentation 来设置PPT文字阴影效果");
shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("隶书");
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;
shape.TextFrame.Paragraphs[0].TextRanges[0].FontHeight = 40;
//实例化OuterShadowEffect类,设置文字阴影效果
Spire.Presentation.Drawing.OuterShadowEffect Shadow = new Spire.Presentation.Drawing.OuterShadowEffect();
Shadow.BlurRadius = 0;
Shadow.Direction = 50;
Shadow.Distance = 10;
Shadow.ColorFormat.Color = Color.Gray;
shape.TextFrame.TextRange.EffectDag.OuterShadowEffect = Shadow;
//保存文档
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
VB.NET
'实例化Presentation类,获取第一张幻灯片
Dim presentation As New Presentation()
Dim slide As ISlide = presentation.Slides(0)
'在幻灯片指定位置绘制指定大小的矩形形状,并设置填形状填充
Dim shape As IAutoShape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(80, 40, 500, 350))
shape.ShapeStyle.LineColor.Color = Color.White
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None
'绘制文本内容到形状,并设置文本格式
shape.AppendTextFrame("如何通过使用Spire.Presentation 来设置PPT文字阴影效果")
shape.TextFrame.Paragraphs(0).TextRanges(0).LatinFont = New TextFont("隶书")
shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.FillType = FillFormatType.Solid
shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.SolidColor.Color = Color.Black
shape.TextFrame.Paragraphs(0).TextRanges(0).FontHeight = 40
'实例化OuterShadowEffect类,设置文字阴影效果
Dim Shadow As New Spire.Presentation.Drawing.OuterShadowEffect()
Shadow.BlurRadius = 0
Shadow.Direction = 50
Shadow.Distance = 10
Shadow.ColorFormat.Color = Color.Gray
shape.TextFrame.TextRange.EffectDag.OuterShadowEffect = Shadow
'保存文档
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)
PPT文字阴影添加效果: