How to Convert ODP to PNG in C# .NET Framework

Cloudmersive
2 min readJan 29, 2024

--

Lightweight PNG arrays are typically much easier to share across networks than bulky Open Document Presentation (ODP) files. However, writing code to enable such a conversion can be a bit of a pain.

Thankfully, using the ready-to-run code examples provided below, we can take advantage of a free API to make ODP to PNG conversions in C# .NET framework. We can submit our ODP files in multipart/form-data requests and return PNG arrays with exactly one image per slide of our original ODP document.

To get started, let’s install the SDK via NuGet. We can do so by running the following command in our Package Manager console:

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

Next, let’s copy the below code to call the function, and let’s include our ODP file data in the appropriate parameters. To authorize our API calls for free, we’ll just need a free-tier API key, which will allow a limit of 800 API calls per month (and no further commitments):

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

var apiInstance = new ConvertDocumentApi();
var inputFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on.

try
{
// Convert ODP Presentation to PNG image array
OdpToPngResult result = apiInstance.ConvertDocumentOdpToPng(inputFile);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentOdpToPng: " + e.Message );
}
}
}
}

Just like that, we’re all done — no more code required! We can now make free ODP to PNG conversions whenever we’d like with zero hassle.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet