How to convert a PDF to PNG array using C# in .NET Framework

While PDF format is generally pretty robust, it can be a bit unwieldy. Sometimes a PNG array works much better, allowing easier web display and image editing. Let’s look at an easy way to accomplish this.

First, install the API client that we will need by running the following command in your Package Manage console:

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

Second, we simply call ConvertDocumentPdfToPngArray:

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 ConvertDocumentPdfToPngArrayExample
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 ConvertDocumentApi();
var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.
// PDF to PNG Array
PdfToPngResult result = apiInstance.ConvertDocumentPdfToPngArray(inputFile);
catch (Exception e)
Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentPdfToPngArray: " + e.Message );

All done! Your return will be a JSON file that contains a URL for each PNG file, making it a simple task to download them.

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