PowerPoint テキストを .NET でアニメーション化
段落へのアニメーション効果の追加
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:
using (Presentation presentation = new Presentation(dataDir + "Presentation1.pptx"))
{
// エフェクトを追加する段落を選択
IAutoShape autoShape = (IAutoShape)presentation.Slides[0].Shapes[0];
IParagraph paragraph = autoShape.TextFrame.Paragraphs[0];
// 選択した段落に Fly アニメーションエフェクトを追加
IEffect effect = presentation.Slides[0].Timeline.MainSequence.AddEffect(paragraph, EffectType.Fly, EffectSubtype.Left, EffectTriggerType.OnClick);
presentation.Save(dataDir + "AnimationEffectinParagraph.pptx", SaveFormat.Pptx);
}
段落のアニメーション効果の取得
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 .NET 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:
using (Presentation pres = new Presentation("Test.pptx"))
{
ISequence sequence = pres.Slides[0].Timeline.MainSequence;
IAutoShape autoShape = (IAutoShape)pres.Slides[0].Shapes[1];
foreach (IParagraph paragraph in autoShape.TextFrame.Paragraphs)
{
IEffect[] effects = sequence.GetEffectsByParagraph(paragraph);
if (effects.Length > 0)
Console.WriteLine("Paragraph \"" + paragraph.Text + "\" has " + effects[0].Type + " effect.");
}
}
よくある質問
テキストアニメーションはスライドトランジションとどのように異なり、組み合わせることはできますか?
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.