# 通过 C++ 合并 PPT 文件

> C++ 示例代码，用于在 Windows 32 位、Windows 64 位和 Linux 64 位的 C++ 运行时环境上组合 PPT 文档。

Source: https://products.aspose.com/slides/zh/cpp/merger/ppt/
Updated: 2026-08-11



## 如何使用 C++ 合并 PPT 文件

 为了合并 PPT 文件，我们将使用
 [Aspose.Slides for C++](https://products.aspose.com/slides/cpp/)
 API 是一个功能丰富、功能强大且易于使用的 C++ 平台文档合并 API。可以直接下载最新版本，直接打开
 [NuGet](https://www.nuget.org/packages/aspose.slides)
 包管理器，搜索
 **Aspose.Slides.Cpp**
 并安装。您也可以从包管理器控制台使用以下命令。

### 命令

```cs

PM> Install-Package Aspose.Slides.Cpp

```

## 在 C++ 中合并 PPT 文件的步骤

只需几行代码即可完成与 [Aspose.Slides for C++](https://products.aspose.com/slides/cpp/) API 合并和连接的基本文档。

加载两个 PPT 文件。

使用 get\_Slides() 方法遍历每张幻灯片。

使用 AddClone 功能与所需文件合并。

使用 Save() 方法保存在指定路径

## 系统要求

 Aspose.Slides for C++ 支持所有主要平台和操作系统。请确保您具有以下先决条件。

- Microsoft Windows 或具有适用于 Windows 32 位、Windows 64 位和 Linux 64 位的 C++ 运行时环境的兼容操作系统。
- 项目中引用的 C++ DLL 的 Aspose.Slides。

### 合并 PPT 文件 - C++

```cs
// The path to the documents directory.
const String sourceFilePath1 = u"SourceFile2.ppt";
const String sourceFilePath2 = u"SourceFile3.ppt";
const String outputFilePath = u"mergedOutput.ppt";

// Instantiate Presentation class
SharedPtr<Presentation> presentation1 = MakeObject<Presentation>(sourceFilePath1);
SharedPtr<Presentation> presentation2 = MakeObject<Presentation>(sourceFilePath2);

for (SharedPtr<ISlide> slide : presentation2->get_Slides()){
	// Merge from source to destination
	presentation1->get_Slides()->AddClone(slide);
}

// Save the presentation
presentation1->Save(outputFilePath, SaveFormat::Ppt);

```

## 关于 Aspose.Slides for C++ API

 Aspose.Slides API 可用于读取、编写、操作 Microsoft PowerPoint 文档并将其转换为 PDF、XPS、HTML、TIFF、ODP 和各种其他格式。可以从头开始创建新文件并将其保存为相关支持的格式。 Aspose.Slides 是一个独立的 API，用于创建、解析或操作演示文稿、幻灯片和元素，它不依赖于 Microsoft 或 OpenOffice 等任何软件。

A file with PPT extension represents PowerPoint file that consists of a collection of slides for displaying as SlideShow. It specifies the Binary File Format used by Microsoft PowerPoint 97-2003. A PPT file can contain several different types of information such as text, bulleted points, images, multimedia and other embedded OLE objects. Microsoft came up with newer file format for PowerPoint, known as PPTX, from 2007 onwards that is based on Office OpenXML and is different from this binary file format. Several other application programs such as OpenOffice Impress and Apple Keynote can also create PPT files.

## 其他支持的合并格式

- [ODP](https://products.aspose.com/slides/cpp/merger/odp/) — OpenDocument 演示格式
- [OTP](https://products.aspose.com/slides/cpp/merger/otp/) — OpenDocument 标准格式
- [POT](https://products.aspose.com/slides/cpp/merger/pot/) — Microsoft PowerPoint 模板文件
- [POTM](https://products.aspose.com/slides/cpp/merger/potm/) — 微软 PowerPoint 模板文件
- [POTX](https://products.aspose.com/slides/cpp/merger/potx/) — Microsoft PowerPoint 模板演示文稿
- [PPS](https://products.aspose.com/slides/cpp/merger/pps/) — 幻灯片放映
- [PPSM](https://products.aspose.com/slides/cpp/merger/ppsm/) — 启用宏的幻灯片放映
- [PPSX](https://products.aspose.com/slides/cpp/merger/ppsx/) — 幻灯片放映
- [PPTM](https://products.aspose.com/slides/cpp/merger/pptm/) — 启用宏的演示文件
- [PPTX](https://products.aspose.com/slides/cpp/merger/pptx/) — 打开 XML 表示格式
