spire.presentation支持为幻灯片中的文本添加带有颜色的文本边框,让文字显示的时候可以拥有描边效果,这样幻灯片中的文字会更美观。该文将详细介绍如何使用spire.presentation为幻灯片中的文字添加文本边框。
在microsoft powerpoint中,选中幻灯片中的shape后,右键“设置文字效果格式”,然后在文本选项中可以看到文本边框,通过设置边框线条样式,颜色,宽度等属性对文本设置描边效果。请查看文字添加了文本边框后的效果图:
spire.presentation如何设置文本选项下的文本边框
c#
//新建一个powerpoint文档
presentation ppt = new presentation();
//设置幻灯片大小和方向
ppt.slidesize.type = slidesizetype.screen16x9;
ppt.slidesize.orientation = slideorienation.landscape;
//设置幻灯片背景填充颜色
ppt.slides[0].slidebackground.type = backgroundtype.custom;
ppt.slides[0].slidebackground.fill.filltype = fillformattype.solid;
ppt.slides[0].slidebackground.fill.solidcolor.color = color.darkseagreen;
//添加一个shape到第一张幻灯片
iautoshape textboxshape = ppt.slides[0].shapes.appendshape(shapetype.rectangle, new rectanglef(50, 70, 700, 100));
textboxshape.shapestyle.linecolor.color = color.transparent;
textboxshape.fill.filltype = spire.presentation.drawing.fillformattype.none;
//清除shape上的段落(默认有一个空白段落)
textboxshape.textframe.paragraphs.clear();
//在shape上添加段落并写入文本
textboxshape.textframe.paragraphs.append(new textparagraph());
textboxshape.textframe.paragraphs[0].textranges.append(new textrange("spire.presentation for .net"));
textboxshape.textframe.paragraphs[0].spaceafter = 50f;
textboxshape.textframe.paragraphs.append(new textparagraph());
string text = "c#设置幻灯片文本边框";
textboxshape.textframe.paragraphs[1].textranges.append(new textrange(text));
//设置段落中文字的字体、大小、颜色,并设置文本边框的填充颜色和宽度
foreach (textparagraph para in textboxshape.textframe.paragraphs)
{
para.textranges[0].latinfont = new textfont("arial rounded mt bold");
para.textranges[0].fontheight = 40f;
para.textranges[0].fill.filltype = fillformattype.solid;
para.textranges[0].fill.solidcolor.color = color.black;
para.textranges[0].textlineformat.fillformat.filltype = fillformattype.solid;
para.textranges[0].textlineformat.fillformat.solidfillcolor.color = color.white;
para.textranges[0].textlineformat.width = 1.52f;
}
//保存文档
ppt.savetofile("result.pptx", fileformat.pptx2013);
vb.net
'新建一个powerpoint文档
dim ppt as new presentation()
'设置幻灯片大小和方向
ppt.slidesize.type = slidesizetype.screen16x9
ppt.slidesize.orientation = slideorienation.landscape
'设置幻灯片背景填充颜色
ppt.slides(0).slidebackground.type = backgroundtype.[custom]
ppt.slides(0).slidebackground.fill.filltype = fillformattype.solid
ppt.slides(0).slidebackground.fill.solidcolor.color = color.darkseagreen
'添加一个shape到第一张幻灯片
dim textboxshape as iautoshape = ppt.slides(0).shapes.appendshape(shapetype.rectangle, new rectanglef(50, 70, 700, 100))
textboxshape.shapestyle.linecolor.color = color.transparent
textboxshape.fill.filltype = spire.presentation.drawing.fillformattype.none
'清除shape上的段落(默认有一个空白段落)
textboxshape.textframe.paragraphs.clear()
'在shape上添加段落并写入文本
textboxshape.textframe.paragraphs.append(new textparagraph())
textboxshape.textframe.paragraphs(0).textranges.append(new textrange("spire.presentation for .net"))
textboxshape.textframe.paragraphs(0).spaceafter = 50f
textboxshape.textframe.paragraphs.append(new textparagraph())
dim text as string = "c#设置幻灯片文本边框"
textboxshape.textframe.paragraphs(1).textranges.append(new textrange(text))
'设置段落中文字的字体、大小、颜色,并设置文本边框的填充颜色和宽度
for each para as textparagraph in textboxshape.textframe.paragraphs
para.textranges(0).latinfont = new textfont("arial rounded mt bold")
para.textranges(0).fontheight = 40f
para.textranges(0).fill.filltype = fillformattype.solid
para.textranges(0).fill.solidcolor.color = color.black
para.textranges(0).textlineformat.fillformat.filltype = fillformattype.solid
para.textranges(0).textlineformat.fillformat.solidfillcolor.color = color.white
para.textranges(0).textlineformat.width = 1.52f
next
'保存文档
ppt.savetofile("result.pptx", fileformat.pptx2013)