How to validate a PowerPoint PPTX Presentation using C# in .NET Framework

PowerPoint file validation is very useful in a variety of mobile app and website applications; for example in filtering out junk files from user submissions to a website, or to prevent issues in a PowerPoint editing app when the wrong type of file is loaded. Programming this functionality from scratch is a headache, but today we are going to accomplish it in two quick steps using an API.

First let’s install Cloudmersive’s Document client using NuGet:

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

Next call ValidateDocumentPptxValidation with the file that needs to be validated.

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 ValidateDocumentPptxValidationExample
public void main()
// Configure API key authorization: Apikey
Configuration.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 ValidateDocumentApi();
var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.
// Validate a PowerPoint presentation (PPTX)
DocumentValidationResult result = apiInstance.ValidateDocumentPptxValidation(inputFile);
catch (Exception e)
Debug.Print("Exception when calling ValidateDocumentApi.ValidateDocumentPptxValidation: " + e.Message );

That’s it! You’re done. Your output will look something like this:

"DocumentIsValid": true,
"ErrorCount": 0,
"WarningCount": 0,
"ErrorsAndWarnings": [
"Description": "string",
"Path": "string",
"Uri": "string",
"IsError": true

This API contains sister functions that cover DOCX and XLSX files should you need them. There are also functions that allow you to manipulate documents and websites in a variety of ways, as well as convert files between formats (for example between PPTX and PDF).\

Image for post
Image for post

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