How to convert a PowerPoint PPTX into a Thumbnail PNG Image in C# .NET Framework

Creating thumbnails from PowerPoint presentations can be such a hassle. If you would rather skip the whole process of parsing, splitting, rendering, and rasterizing, I won’t fault you one iota. Instead, I will show you a nice simple means of creating thumbnails with a single function call. Trust me when I say that this will save you hours of coding and testing.

First let’s install the client library that we are going to be making use of.

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

Once that’s done with, we can continue on to our function call, which goes like this example here:

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 ConvertDocumentAutodetectToThumbnailExample{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 ConvertDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.var maxWidth = 56;  // int? | Optional; Maximum width of the output thumbnail - final image will be as large as possible while less than or equal to this width. Default is 128. (optional)var maxHeight = 56;  // int? | Optional; Maximum height of the output thumbnail - final image will be as large as possible while less than or equal to this width. Default is 128. (optional)var extension = extension_example;  // string | Optional; Specify the file extension of the inputFile. This will improve the response time in most cases. Also allows unsupported files without extensions to still return a corresponding generic icon. (optional)try{// Convert File to Thumbnail Imagebyte[] result = apiInstance.ConvertDocumentAutodetectToThumbnail(inputFile, maxWidth, maxHeight, extension);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentAutodetectToThumbnail: " + e.Message );}}}}

And that’s it! Now any document file that you input into ConvertDocumentAutodetectToThumbnail (including EML, but many others as well) will be converted into a customizable thumbnail image automatically.

Image for post
Image for post

Written by

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