How to Convert a Document to a JPG Array using C# .NET Framework
Converting any content to JPG format results in a lightweight, easily sharable version of that content. With a low-code API solution to handle that conversion for us, we can scale our conversion operations easily.

Using the ready-to-run code examples provided below, we can take advantage of a free API that converts a variety of common document types — including all major Office formats, PDFs, HTML files, and over 100+ image formats — to JPG image arrays. In our API request, we can even specify the quality of our resulting images to further compress content & reduce file size.
We can begin structuring our API call by installing the SDK. Let’s first run the following command in our Package Manager console to install via NuGet:
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.4.2
Next, let’s grab a free API key to authorize our API calls. These allow a limit of 800 API calls per month with no commitments; once we reach our total, it’ll reset the following month.
Finally, let’s copy the examples below to call the function. Let’s make sure we include our file content for a multipart/form-data request, and let’s set our JPG compression value (1 = highest compression; 100 = lowest compression; default = 75):
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 ConvertDocumentAutodetectToJpgExample
{
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.
var quality = 56; // int? | Optional; Set the JPEG quality level; lowest quality is 1 (highest compression), highest quality (lowest compression) is 100; recommended value is 75. Default value is 75. (optional)
try
{
// Convert Document to JPG/JPEG image array
AutodetectToJpgResult result = apiInstance.ConvertDocumentAutodetectToJpg(inputFile, quality);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentAutodetectToJpg: " + e.Message );
}
}
}
}
That’s all there is to it — no we can convert a variety of common document types to JPG arrays with zero hassle & minimal code.