创建演示文稿 - C++ PowerPoint API

创建 PowerPoint 演示文稿

要在选定的演示文稿幻灯片上添加一条简单的纯线,请按照以下步骤操作:

  1. 创建一个 Presentation 类的实例。
  2. 使用索引获取幻灯片的引用。
  3. 使用 Shapes 对象公开的 AddAutoShape 方法添加一条线类型的 AutoShape。
  4. 将修改后的演示文稿写入 PPTX 文件。

在下面给出的示例中,我们已将一条线添加到演示文稿的第一张幻灯片上。

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"../out/SampleChartresult.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an autoshape of type line
slide->get_Shapes()->AddAutoShape(Aspose::Slides::ShapeType::Line, 50.0, 150.0, 300.0, 0.0);
//Saving presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);