本文介绍使用Spire.Presentation for Java来自定义PPT中的项目符号样式,即通过加载指定logo图片来设置为符号样式。
import com.spire.presentation.*;
import com.spire.presentation.IAutoShape;
import com.spire.presentation.drawing.FillFormatType;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
public class CustomStyle {
    public static void main(String[] args) throws Exception{
        //实例化Presentation类的对象
        Presentation ppt = new Presentation();
        //获取第一张幻灯片(新建的PPT文档默认包含一张幻灯片)
        ISlide slide = ppt.getSlides().get(0);
        //添加shape到幻灯片
        IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle2D.Float(200,50,200,150));
        shape.getTextFrame().getParagraphs().clear();//删除形状中默认的段落
        shape.getShapeStyle().getLineColor().setColor(Color.white);//设置形状边框颜色
        shape.getFill().setFillType(FillFormatType.NONE);//形状无背景填充
        shape.getTextFrame().setText("开发\n测试\n技术支持\n销售\n综合");//添加文本到形状
        //遍历shape中的所有段落
        for (int i = 0; i< shape.getTextFrame().getParagraphs().getCount();i++)
        {
            ParagraphEx paragraph = shape.getTextFrame().getParagraphs().get(i);//获取段落
            paragraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID);
            paragraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black);
            paragraph.setBulletType(TextBulletType.PICTURE);//设置项目符号样式为图片
            BufferedImage image = ImageIO.read(new File("g.png"));//加载图片
            paragraph.getBulletPicture().setEmbedImage(ppt.getImages().append(image));//添加图片作为项目符号样式
        }
        //保存文档
        ppt.saveToFile("CustomStyle.pptx", FileFormat.PPTX_2013);
        ppt.dispose();
    }
}添加效果:

 
    


 
					



