在之前的文章中我们介绍了如何给PowerPoint文档中的形状添加动画效果,在这篇文章中我们将介绍如何给PowerPoint文档中的指定段落添加动画效果。
import com.spire.presentation.*;
import com.spire.presentation.drawing.FillFormatType;
import com.spire.presentation.drawing.animation.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;
public class AddAnimationOnParagraph {
    public static void main(String[] args) throws Exception {
        //创建Presentation实例
        Presentation ppt = new Presentation();
        //获取第一张幻灯片
        ISlide slide = ppt.getSlides().get(0);
        //添加一个形状到幻灯片
        IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle2D.Double(150, 150, 450, 100));
        shape.getFill().setFillType(FillFormatType.SOLID);
        shape.getFill().getSolidColor().setColor(Color.gray);
        shape.getShapeStyle().getLineColor().setColor(Color.white);
        shape.appendTextFrame("This demo shows how to apply animation on paragraph in PPT document.");
        //给形状中的第一个段落添加动画效果
        AnimationEffect animation = shape.getSlide().getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.FLOAT);
        animation.setStartEndParagraphs(0, 0);
        //保存结果文档
        ppt.saveToFile("AddAnimationOnPara.pptx", FileFormat.PPTX_2013);
        ppt.dispose();
    }
}效果图:

 



 
					



