添加幻灯片到演示文稿
Contents
[
Hide
]
添加幻灯片到演示文稿
在讨论如何将幻灯片添加到演示文稿文件之前,我们先讨论一些关于幻灯片的事实。每个 PowerPoint 演示文稿文件包含主幻灯片 / 布局幻灯片和其他普通幻灯片。这意味着一个演示文稿文件包含至少一个或多个幻灯片。重要的是要知道,Aspose.Slides for C++ 不支持没有幻灯片的演示文稿文件。每个幻灯片都有唯一的 Id,所有普通幻灯片按零基索引指定的顺序排列。Aspose.Slides for C++ 允许开发者向他们的演示文稿添加空幻灯片。要在演示文稿中添加空幻灯片,请按照以下步骤操作:
- 创建一个 Presentation 类的实例。
- 通过设置对演示文稿对象暴露的幻灯片(内容幻灯片对象集合)属性的引用来实例化 ISlideCollection 类。
- 通过调用 ISlideCollection 对象暴露的 AddEmptySlide 方法,将空幻灯片添加到内容幻灯片集合的末尾。
- 对新添加的空幻灯片进行一些操作。
- 最后,使用 Presentation 对象写入演示文稿文件。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C | |
// The path to the documents directory. | |
const String outPath = u"../templates/AddSlides.pptx"; | |
// Instantiate Presentation class that represents the presentation file | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(); | |
// Instantiate SlideCollection calss | |
SharedPtr<ISlideCollection> slds = pres->get_Slides(); | |
for (int i = 0; i < pres->get_LayoutSlides()->get_Count(); i++) | |
{ | |
// Add an empty slide to the Slides collection | |
slds->AddEmptySlide(pres->get_LayoutSlides()->idx_get(i)); | |
} | |
// Save the PPTX file to the Disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |