How to merge two PowerPoint PPTX files together in C# .NET Framework

Merging PowerPoint files is the subject of today’s lesson. This is a snap if you follow our quick and easy method.

First up: API client installation. No problem, just run this command in Package Manager.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0

With that done, we can input our PPTX files right into MergeDocumentPptx, as laid out below:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class MergeDocumentPptxExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new MergeDocumentApi();var inputFile1 = new System.IO.Stream(); // System.IO.Stream | First input file to perform the operation on.var inputFile2 = new System.IO.Stream(); // System.IO.Stream | Second input file to perform the operation on (more than 2 can be supplied).try{// Merge Two PowerPoint PPTX Togetherbyte[] result = apiInstance.MergeDocumentPptx(inputFile1, inputFile2);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling MergeDocumentApi.MergeDocumentPptx: " + e.Message );}}}}

Done! The contents of inputFile2 will, of course, be placed after inputFile 1, which allows you to repeat this function with as many files as you like and have control over the order in the completed file.

Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store