How to convert any Document File into PNG Array in C# .NET Framework
1 min readJul 20, 2020
Today we will be using PNG as the great leveler, converting all of our document files to this format automatically to maximize convenience and compatibility. Creating such a system manually would take some serious time, especially for identifying and parsing the source file format. If you’d rather just get on with your day, I have the perfect solution for you.
First we will need to download our package using NuGet:
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8
Now we can go ahead and call our function, with this sample code as a model.
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 ConvertDocumentAutodetectToPngArrayExample{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.try{// Convert Document to PNG arrayAutodetectToPngResult result = apiInstance.ConvertDocumentAutodetectToPngArray(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentAutodetectToPngArray: " + e.Message );}}}}
And just like that, you have document conversion. Easy.