目录
用于在 PowerPoint 演示文稿中添加过渡的 C++ API
在 Microsoft PowerPoint 中设置变形过渡
使用 C++ 在 PowerPoint 演示文稿中设置变形过渡
幻灯片切换是在从一张幻灯片导航到另一张幻灯片时显示的效果。这些增强了演示文稿的外观和感觉,并使它们更具吸引力。在某些情况下,可能需要以编程方式将幻灯片切换添加到 PowerPoint 文件。为此,本文将教您如何使用 C++ 向 PowerPoint 幻灯片添加过渡。
Aspose.Slides for C++ 是一个用于处理 PowerPoint 文件的 C++ API。它无需安装 Microsoft PowerPoint 即可创建、阅读和更新 PowerPoint 文件。此外,该 API 允许向 PowerPoint 演示文稿添加幻灯片过渡。
以下是在 PowerPoint 演示文稿中添加幻灯片切换的步骤。
以下示例代码演示了如何使用 C++ 向 PowerPoint 幻灯片添加过渡。
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddTransition_out.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// Apply circle type transition on slide 1
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Apply comb type transition on slide 2
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
以下是使用 C++ 向幻灯片添加高级过渡的步骤。
以下示例代码显示了如何使用 C++ 添加高级幻灯片过渡。
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddAdvancedTransition_out.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// Apply circle type transition on slide 1
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Set the transition time of 3 seconds
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceOnClick(true);
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceAfterTime(3000);
// Apply comb type transition on slide 2
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Set the transition time of 5 seconds
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceOnClick(true);
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceAfterTime(5000);
// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
在演示文稿中使用变形过渡来制作幻灯片之间的平滑过渡动画。以下部分介绍了如何在 Microsoft PowerPoint 中以及如何使用 C++ 以编程方式添加变形过渡。
以下是在 Microsoft PowerPoint 中添加变形过渡的步骤。
与 Microsoft PowerPoint 类似,Aspose.Slides for C++ API 提供以下变形过渡效果。
以下是使用 C++ 在 PowerPoint 演示文稿中设置变形过渡的步骤。
以下示例代码显示了如何使用 C++ 在 PowerPoint 演示文稿中设置变形过渡。
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddMorphTransition_out.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// Add morph transition
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Morph);
auto morphTransition = System::DynamicCast<Aspose::Slides::SlideShow::IMorphTransition>(presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->get_Value());
morphTransition->set_MorphType(Aspose::Slides::SlideShow::TransitionMorphType::ByWord);
// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);