How to Split a PowerPoint Presentation into Separate Slides in C# .NET Framework

Cloudmersive
2 min readFeb 16, 2024

--

Each slide in a PowerPoint presentation can offer value in a variety of different use-cases. With a low-code solution, we can slice & dice our PowerPoint slides into separate documents with ease.

Using the below code, we can take advantage of a free, low-code API that will divide a single PowerPoint presentation into an array of presentations. Each presentation will have exactly one slide from the original document.

To make our API call, let’s start by grabbing an API key. We can get one for free, and it will allow us to make up to 800 API calls per month with no commitments.

After that, we can go about installing the SDK. Let’s run this command in our Package Manager console to install via NuGet:

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

Next, let’s call our function using the below code. We can copy our API key into the “Your API key” snippet and load in our PowerPoint file right after:

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 SplitDocumentPptxExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");

var apiInstance = new SplitDocumentApi();
var inputFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on.
var returnDocumentContents = true; // bool? | Set to true to return the contents of each presentation directly, set to false to only return URLs to each resulting presentation. Default is true. (optional)

try
{
// Split a single PowerPoint Presentation PPTX into Separate Slides
SplitPptxPresentationResult result = apiInstance.SplitDocumentPptx(inputFile, returnDocumentContents);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling SplitDocumentApi.SplitDocumentPptx: " + e.Message );
}
}
}
}

Now we can run our code and write the PresentationContents from our response objects to new PPTX documents. Just like that, we have a quick method for divvying up our PowerPoint files!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet