Merge PowerPoint Presentations using C++

Merge PowerPoint Presentations using C++

PowerPoint presentations are used in many scenarios such as meetings, presentations, discussions, etc. There might be situations where you have different presentations created by separate people or have individual presentations used in various meetings. You might need to merge these presentations for sharing or documentation purposes. Doing this task manually would be time-consuming. The efficient way would be to achieve this programmatically. In this article, you will learn how to merge PowerPoint presentations using C++.

C++ API to Merge PowerPoint Presentations

Aspose.Slides for C++ is a C++ library that provides a bunch of features for working with PowerPoint presentations. The API allows you to create, modify and convert PowerPoint presentations without using Microsoft PowerPoint. Furthermore, the API provides the ability to merge different PowerPoint files. You can either install the API through NuGet or download it directly from the Downloads section.

PM> Install-Package Aspose.Slides.Cpp

Merge PowerPoint Presentations using C++

The process for merging two presentations using Aspose.Slides for C++ is a breeze. To achieve this, you load both the presentations, loop through the source presentation slides, and add their clone to the target presentation. The following are the steps to merge two PowerPoint presentations.

The following is the sample code to merge PowerPoint presentations using C++.

The following images show the source, destination and merged presentation files.

Destination Presentation

Destination PowerPoint presentation image
Destination PowerPoint presentation image.

Source Presentation

Source PowerPoint presentation image.
Source PowerPoint presentation image.

Merged Presentation

Merged PowerPoint presentation image
Merged PowerPoint presentation image.

Merge Specific PowerPoint Slides using C++

There might be situations where you are not interested in the whole presentation but instead, want to add a subset of slides. To achieve this, you add the necessary condition while looping through the source presentation slides. The following are the steps to merge selected PowerPoint slides.

The following is the sample code to merge selected PowerPoint slides using C++.

The following image shows the merged presentation file. The source and the destination presentation files are the same as used in the previous example.

Merged Presentation

Merged PowerPoint presentation with selected slides added
Merged PowerPoint presentation with selected slides added.

Use Slide Master to Merge PowerPoint Presentations

In the previous two examples, the design of both the source and destination presentations was the same. The following images show the result of merging presentations with different designs.

Destination Presentation

Destination PowerPoint presentation image
Destination PowerPoint presentation image.

Source Presentation

Source PowerPoint presentation image
Source PowerPoint presentation image.

Merged Presentation

Merged PowerPoint presentation with the first slide added
Merged PowerPoint presentation with the first slide added.

You can see in the merged presentation image that the third slide retained its original styling during the merge process. If you want the source slides to use the destination presentation styles, please use the following steps.

The following is the sample code to merge PowerPoint presentations using slide master.

The following image shows the merged presentation generated by the above sample code.

Merged Presentation

Merged PowerPoint presentation with the first slide added using the destination presentation styles
Merged PowerPoint presentation with the first slide added using the destination presentation styles.

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, you have learned how to merge multiple PowerPoint presentations using C++. You have seen how to merge complete presentations or selected slides. Furthermore, you have learned how to use the style of the destination presentation for combining the presentations. Aspose.Slides for C++ offers many additional features for working with PowerPoint files. You can explore the API in detail by using the official documentation. If you have any questions, please feel free to contact us on the forum.

See Also