Convert JPG to Word

Convert JPG to Word using Java Cloud SDK

Raster images are ideal for photo editing and creating digital paintings because, they are compressed for storage and are optimized for web. Many of our daily life gadgets including digital cameras, optical scanners etc. Now the popular types of raster files include JPEG, PNG, and GIF images and in this article, we are going to discuss the details on how to convert JPG to Word. The reason we are converting JPEG to Word is because, we may have a requirement to combine a collection of JPG images in a single document and then stored in official archive. So let’s explore the details on how to Develop JPG to Word converter using Java Cloud SDK

JPG to Word Conversion API

Our award winning product Aspose.Word Cloud is a Low Code API and a reliable solution offering the capabilities to create, edit as well as transform Word documents to variety of supported formats. If you are looking to implement Word document manipulation capabilities in Java application, then Aspose.Words Cloud SDK for Java is an amazing choice. So without using any software or MS Office automation, you can programmatically generate, edit and convert MS Word documents in the Cloud. Now in order to get started with SDK utilization, we need to add the Cloud SDK reference in our project. So please add following details in pom.xml of maven build type project.



In order to use the SDK, we need to authenticate our user with Aspose Cloud. So if you do not have an existing account, please create a free account using valid email address. Then login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required for authentication purposes in the following sections.

Convert JPG to Word in Java

This section explains the details on how we can develop JPG to Word converter using Java Cloud SDK. Please follow the instructions specified below.

  • First of all, please create an object of WordsApi object while providing ClientID and Client secret as arguments
  • Secondly, create an object of CreateDocumentRequest which requires name of new Word document
  • Thirdly, create blank word document and upload to Cloud Storage using createDocument(…) method
  • Next step is to create an object of DrawingObjectInsert so that drawing object can be placed inside word document
  • Set margin, dimensions and Alignment information for the drawing object
  • Read image file from local drive into ByteArray
  • Now create an object of InsertDrawingObjectRequest providing input Word file name and node details to hold drawing object
  • Finally call the insertDrawingObject(…) method to insert Drawing object inside Word document and save the output in Cloud Storage
JPG to Word

Image1:- JPG to Word Preview

The sample files used in above example can be downloaded from Tulips.jpeg and Resultant.docx.

JPG to DOC using cURL Commands

In this section, we are going to use the cURL commands to convert JPG to DOC. We are using cURL commands because they enable us to access REST APIs through command line terminal. Now as a pre-requisite for this approach, first we need to generate a JWT access token (based on client credentials) while executing the following command.

curl -v "" \
-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"

Once we have the JWT token, the next step is to create a blank Word document using following command.

curl -v -X PUT "" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>"

Now that the blank Word document is generated, we need to insert Drawing object containing JPG image inside DOCX file

curl -v -X POST "" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d {"drawingObject":"{  \"RelativeHorizontalPosition\": \"Margin\",  \"Left\": 0,  \"RelativeVerticalPosition\": \"Margin\",  \"Top\": 0,  \"Width\": 0,  \"Height\": 0,  \"WrapType\": \"Inline\"}","imageFile":{"Tulips.jpg"}}


In this article, we have learned about the details to convert JPG to Word using Java Cloud SDK. Apart from code snippet, we have also explored the options for converting JPG to DOC using cURL Commands. The product Documentation is enriched with an array of amazing topics further explaining the capabilities of this API. Furthermore, please note that all our Cloud SDKs are published under MIT license, so you may consider downloading the complete source code from GitHub and modify it as per your requirements. In case of any issues, you may consider approaching us for a quick resolution via free product support forum.

Please visit the following links to learn more about: