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文字到幻灯片的效果图: