How to Convert DocX Files to JPG/JPEG Image Arrays using Java

Converting Word Documents to Image Arrays is a great way to make the contents of those documents readable across any operating system. If you’re looking to make that conversion to JPG, we can help: our DocX to JPG Conversion API will make it possible to build that operation into your application and customize the output image quality. To help you structure your API call, we’ve provided instructions to use complementary, ready-to-run code in Java below.

Let’s begin by installing the Java SDK. To do so with Maven, first add a reference to the repository in pom.xml:


Then, add a reference to the dependency in pom.xml:


Lastly, it’s time to include the import classes and call the API:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.ConvertDocumentApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
ConvertDocumentApi apiInstance = new ConvertDocumentApi();
File inputFile = new File("/path/to/inputfile"); // File | Input file to perform the operation on.
Integer quality = 56; // Integer | 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.
try {
DocxToJpgResult result = apiInstance.convertDocumentDocxToJpg(inputFile, quality);
} catch (ApiException e) {
System.err.println("Exception when calling ConvertDocumentApi#convertDocumentDocxToJpg");

Make sure to include your Cloudmersive API key where indicated in the documentation, and you’re all set. To get a key, head to our website and register a free account.



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


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