使用spire.presentation,可以。此外,也可以通过自定义方式来设置项目符号样式。spire.presentation提供了bulletpicture属性,允许用户通过加载图片来作为项目符号样式。本文将介绍具体的实现方法。
c#
//实例化presentation类的对象
presentation ppt = new presentation();
//加载ppt测试文档
ppt.loadfromfile("test.pptx");
//获取第1张幻灯片中的第1个shape
iautoshape shape = ppt.slides[0].shapes[0] as iautoshape;
//遍历shape中的所有段落
foreach (textparagraph paragraph in shape.textframe.paragraphs)
{
//设置项目符号样式为图片
paragraph.bullettype = textbullettype.picture;
//加载图片
image bulletpicture = image.fromfile(@"g.png");
//添加图片作为项目符号样式
paragraph.bulletpicture.embedimage = ppt.images.append(bulletpicture);
}
//保存文档
ppt.savetofile("output.pptx", fileformat.pptx2010);
vb.net
'实例化presentation类的对象
dim ppt as new presentation()
'加载ppt测试文档
ppt.loadfromfile("test.pptx")
'获取第1张幻灯片中的第1个shape
dim shape as iautoshape = trycast(ppt.slides(0).shapes(0), iautoshape)
'遍历shape中的所有段落
for each paragraph as textparagraph in shape.textframe.paragraphs
'设置项目符号样式为图片
paragraph.bullettype = textbullettype.picture
'加载图片
dim bulletpicture as image = image.fromfile("g.png")
'添加图片作为项目符号样式
paragraph.bulletpicture.embedimage = ppt.images.append(bulletpicture)
next
'保存文档
ppt.savetofile("output.pptx", fileformat.pptx2010)
项目符号样式添加效果: