PPT处理控件Aspose.Slides功能演示:使用 C++ 在 PowerPoint 演示文稿中添加幻灯片切换

>>你可以点击这里下载Aspose.Slides 最新版测试体验。

用于在 PowerPoint 演示文稿中添加过渡的 C++ API

Aspose.Slides for C++ 是一个用于处理 PowerPoint 文件的 C++ API。它无需安装 Microsoft PowerPoint 即可创建、阅读和更新 PowerPoint 文件。此外,该 API 允许向 PowerPoint 演示文稿添加幻灯片过渡。

使用 C++ 添加幻灯片过渡

以下是在 PowerPoint 演示文稿中添加幻灯片切换的步骤。

  • 首先,使用Presentation 类加载 PowerPoint 文件 。
  • 使用Presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(SlideShow::TransitionType 值)方法设置幻灯片过渡。
  • 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码演示了如何使用 C++ 向 PowerPoint 幻灯片添加过渡。

// File pathsconst String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";const String outputFilePath = u"OutputDirectory\AddTransition_out.pptx";// Load the presentation fileauto presentation = System::MakeObject<Presentation>(sourceFilePath);// Apply circle type transition on slide 1presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);// Apply comb type transition on slide 2presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);// Save Presentationpresentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

使用 C++ 添加高级幻灯片过渡

以下是使用 C++ 向幻灯片添加高级过渡的步骤。

  • 首先,使用Presentation 类加载 PowerPoint 文件 。
  • 使用ISlideShowTransition类设置过渡类型和其他过渡效果。
  • 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码显示了如何使用 C++ 添加高级幻灯片过渡。

// File pathsconst String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";const String outputFilePath = u"OutputDirectory\AddAdvancedTransition_out.pptx";// Load the presentation fileauto presentation = System::MakeObject<Presentation>(sourceFilePath);// Apply circle type transition on slide 1presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);// Set the transition time of 3 secondspresentation->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 2presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);// Set the transition time of 5 secondspresentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceOnClick(true);presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceAfterTime(5000);// Save Presentationpresentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

在 PowerPoint 演示文稿中设置变形过渡类型

在演示文稿中使用变形过渡来制作幻灯片之间的平滑过渡动画。以下部分介绍了如何在 Microsoft PowerPoint 中以及如何使用 C++ 以编程方式添加变形过渡。

在 Microsoft PowerPoint 中设置变形过渡

以下是在 Microsoft PowerPoint 中添加变形过渡的步骤。

  • 打开“过渡”选项卡。
  • 选择变形过渡类型。
  • 要选择过渡效果,请在“过渡”选项卡中选择“效果选项” 。

使用 C++ 在 PowerPoint 演示文稿中设置变形过渡

与 Microsoft PowerPoint 类似,Aspose.Slides for C++ API 提供以下变形过渡效果。

  • ByObject:将执行变形过渡,将形状视为不可分割的对象。
  • ByWord:变形转换将通过在可能的情况下逐字传输文本来执行。
  • ByChar:变形转换将通过在可能的情况下按字符传输文本来执行。

以下是使用 C++ 在 PowerPoint 演示文稿中设置变形过渡的步骤。

  • 使用Presentation 类加载 PowerPoint 文件 。
  • 将过渡类型设置为morph。
  • 使用IMorphTransition->set_MorphType(TransitionMorphType value)方法设置变形过渡效果。
  • 使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码显示了如何使用 C++ 在 PowerPoint 演示文稿中设置变形过渡。

// File pathsconst String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";const String outputFilePath = u"OutputDirectory\AddMorphTransition_out.pptx";// Load the presentation fileauto presentation = System::MakeObject<Presentation>(sourceFilePath);// Add morph transitionpresentation->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 Presentationpresentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。


还想要更多吗可以点击阅读【Aspose最新资源在线文库】查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年9月24日
下一篇 2021年9月24日

相关推荐

发表回复

登录后才能评论