Spire.Presentation for .NET支持为幻灯片中的文字,形状设置3D效果。本文将介绍如何添加3D 效果的文字到PowerPoint幻灯片。
C#
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace 3DEffectForText
{
class Program
{
static void Main(string[] args)
{
//实例化Presentation类
Presentation presentation = new Presentation();
//获取第一张幻灯片
ISlide slide = presentation.Slides[0];
//添加矩形到幻灯片指定位置
IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(30, 40, 600, 200));
shape.ShapeStyle.LineColor.Color = Color.White;
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
//绘制文本内容到形状,并设置文本大小和字体
shape.AppendTextFrame("3D文字,谢谢观赏!");
TextRange textRange = shape.TextFrame.TextRange;
textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
textRange.Fill.SolidColor.Color = Color.White;
textRange.FontHeight = 30;
textRange.LatinFont = new TextFont("隶书");
//为文本设置3D效果
shape.TextFrame.TextThreeD.ShapeThreeD.PresetMaterial = PresetMaterialType.Matte;
shape.TextFrame.TextThreeD.LightRig.PresetType = PresetLightRigType.Sunrise;
shape.TextFrame.TextThreeD.ShapeThreeD.TopBevel.PresetType = BevelPresetType.Circle;
shape.TextFrame.TextThreeD.ShapeThreeD.ContourColor.Color = Color.Green;
shape.TextFrame.TextThreeD.ShapeThreeD.ContourWidth = 3;
//保存文档
presentation.SaveToFile("3DEffectForText_result.pptx", FileFormat.Pptx2010);
}
}
}
VB.NET
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing
Namespace 3DEffectForText
Class Program
Private Shared Sub Main(args As String())
'实例化Presentation类
Dim presentation As New Presentation()
'获取第一张幻灯片
Dim slide As ISlide = presentation.Slides(0)
'添加矩形到幻灯片指定位置
Dim shape As IAutoShape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(30, 40, 600, 200))
shape.ShapeStyle.LineColor.Color = Color.White
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None
'绘制文本内容到形状,并设置文本大小和字体
shape.AppendTextFrame("3D文字,谢谢观赏!")
Dim textRange As TextRange = shape.TextFrame.TextRange
textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid
textRange.Fill.SolidColor.Color = Color.White
textRange.FontHeight = 30
textRange.LatinFont = New TextFont("隶书")
'为文本设置3D效果
shape.TextFrame.TextThreeD.ShapeThreeD.PresetMaterial = PresetMaterialType.Matte
shape.TextFrame.TextThreeD.LightRig.PresetType = PresetLightRigType.Sunrise
shape.TextFrame.TextThreeD.ShapeThreeD.TopBevel.PresetType = BevelPresetType.Circle
shape.TextFrame.TextThreeD.ShapeThreeD.ContourColor.Color = Color.Green
shape.TextFrame.TextThreeD.ShapeThreeD.ContourWidth = 3
'保存文档
presentation.SaveToFile("3DEffectForText_result.pptx", FileFormat.Pptx2010)
End Sub
End Class
End Namespace
添加3D文字到幻灯片的效果图: