word to jpg

Convert Word to JPG in C# .NET

In today’s digital era, images play a vital role in many aspects of our lives, be it social media, marketing, or education. One of the challenges users face is converting their Word documents(DOC, DOCX) into image formats such as JPG. There are many situations where this conversion is necessary, such as creating brochures, flyers, presentations, and web pages. While there are many online tools available to perform this task, they often come with certain limitations such as file size, privacy concerns, and limited customization options. In this article, we will explore how to convert Word documents to JPG using C# .NET and REST API.

Word to JPG Conversion REST API

Aspose.Words Cloud is a RESTful API that allows you to perform a variety of document processing tasks in the cloud. The API supports a wide range of document formats, including Microsoft Word, PDF, HTML, EPUB, and more. By using Aspose.Words Cloud, you can easily convert Word documents to JPG images without the need for any additional software or libraries.

Now, as per the scope of this article, we are going to use Aspose.Words Cloud SDK for .NET, which is a wrapper around cloud REST API. Therefore, search Aspose.Words-Cloud in NuGet packages manager and click the Add Package button to add the reference of SDK in .NET project. Secondly, obtain your client credentials from Cloud dashboard.

Word to JPG Conversion in C#

This section explains the steps to develop Word to JPG converter online using C# .NET.

word to jpg

Image:- Word to JPG conversion preview.

Now lets develop our understanding regarding above code snippet.

var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
var wordsApi = new WordsApi(config);

Create an object of Configuration and WordsApi instance where client credentials are used as arguments.

var inputStream = System.IO.File.OpenRead(inputFile);

Read the content of input Word document.

var response = new ConvertDocumentRequest(inputStream, format: format, outPath: resultant);

Create an instance of ConvertDocument request object where we provide input word file stream, resultant format as JPG and path for output image.


Call this method to initiate Word to Image conversion operation. After successful conversion, the resultant JPG is storage in cloud storage.

If we skip the outPath argument, the resultant JPG will be returned in response stream.

The input word document used in the above example can be downloaded from input-sample.docx.

DOC to JPG using cURL Commands

It is also possible to perform Word document to JPG conversion using cURL commands and Aspose.Words Cloud REST API. The API provides a powerful and flexible way to perform various document processing operations in the cloud. Furthermore, using cURL commands, you can easily integrate the Aspose.Words Cloud API into your applications and automate the process of converting Word documents to JPG format.

So first we need to first generate the JWT access token (based on client credentials) using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now please execute the following command which loads the input Word document from cloud storage and performs Word to JPG conversion. As we have used -o argument, so the resultant JPG image will be stored on local drive.

curl -v "https://api.aspose.cloud/v4.0/words/{inputFile}?format=JPG" \
-X GET \
-H "accept: application/octet-stream" \
-H "Authorization: Bearer {accessToken}" \
-o "{resultantFile}"

Replace {inputFile} with the name of input Word document in Cloud storage, {accessToken} with JWT access token generated above and {resultantFile} with name/path to save the resultant JPG on local drive.


In conclusion, converting Word documents to JPG images can be a useful tool for a variety of applications. With the help of Aspose.Words Cloud SDK for .NET, this conversion can be performed easily and efficiently within C# programming language. Alternatively, if you prefer to use cURL commands, Aspose.Words Cloud API can also be accessed via REST API, allowing for convenient and flexible usage. Whether you choose to use Aspose.Words Cloud SDK for .NET or cURL commands, the end result will be high-quality JPG images of your Word documents that can be used in a wide range of applications.

Please visit the following links to learn more about: