News Category

Add Animation Effect to Paragraph in PowerPoint in Java

2020-10-26 09:41:41 Written by  support iceblue
Rate this item
(0 votes)

We have already introduced how to add animation effect to shape in PowerPoint, in this article, we will introduce how to add animation effect to paragraph in PowerPoint using Spire.Presentation for Java.

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 {
        //Create a Presentation instance
        Presentation ppt = new Presentation();

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Add a shape to the slide
        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.");

        //Add animation effect to the first paragraph in the shape
        AnimationEffect animation = shape.getSlide().getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.FLOAT);
        animation.setStartEndParagraphs(0, 0);

        //Save the result document
        ppt.saveToFile("AddAnimationOnPara.pptx", FileFormat.PPTX_2013);
        ppt.dispose();
    }
}

Output:

Add Animation Effect to Paragraph in PowerPoint in Java

Additional Info

  • tutorial_title:
Last modified on Thursday, 02 September 2021 06:00