JavaでPowerPointテキストをアニメーション化

段落にアニメーション効果を追加する

We added the addEffect() method to the Sequence and ISequence classes. This method allows you to add animation effects to a single paragraph. This sample code shows you how to add an animation effect to a single paragraph:

Presentation presentation = new Presentation("Presentation.pptx");
try {
    // 効果を追加する段落を選択
    IAutoShape autoShape = (IAutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    // 選択した段落にFlyアニメーション効果を追加
    IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().
            addEffect(paragraph, EffectType.Fly, EffectSubtype.Left, EffectTriggerType.OnClick);

    presentation.save("AnimationEffectinParagraph.pptx", SaveFormat.Pptx);
} finally {
    if (presentation != null) presentation.dispose();
}

段落のアニメーション効果を取得する

You may decide to find out the animation effects added to a paragraph—for example, in one scenario, you want to get the animation effects in a paragraph because you plan to apply those effects to another paragraph or shape.

Aspose.Slides for Java allows you to get all the animation effects applied to paragraphs contained in a text frame (shape). This sample code shows you how to get the animation effects in a paragraph:

Presentation pres = new Presentation("Presentation.pptx");
try {
    ISequence sequence = pres.getSlides().get_Item(0).getTimeline().getMainSequence();
    IAutoShape autoShape = (IAutoShape)pres.getSlides().get_Item(0).getShapes().get_Item(0);

    for (IParagraph paragraph : autoShape.getTextFrame().getParagraphs())
    {
        IEffect[] effects = sequence.getEffectsByParagraph(paragraph);

        if (effects.length > 0)
            System.out.println("Paragraph \"" + paragraph.getText() + "\" has " + effects[0].getType() + " effect.");
    }
} finally {
    pres.dispose();
}

FAQ

テキストアニメーションはスライドトランジションとどのように異なり、組み合わせて使用できますか?

Text animations control object behavior over time on a slide, while トランジション control how slides change. They’re independent and can be used together; playback order is governed by the animation timeline and the transition settings.

テキストアニメーションは PDF や画像にエクスポートしたときに保持されますか?

No. PDF and raster images are static, so you’ll see a single state of the slide without motion. To keep movement, use ビデオ or HTML export.

テキストアニメーションはレイアウトやスライドマスターでも機能しますか?

Effects applied to layout/master objects are inherited by slides, but their timing and interaction with slide-level animations depend on the final sequence on the slide.