html to doc

How to convert HTML to DOC in Java

The content placed inside HTML can be viewed on any platform but it gets really difficult to manipulate HTML content because there are few UI-based editors for HTML files. So one of the convenient approaches is to convert HTML to DOC format and use the Word document editor to update the content. In this article, we are going to discuss the details on how to develop an HTML to DOC converter using Java.

HTML to DOC conversion API

Aspose.Words Cloud for Java enables Java developers to implement Word file conversion operations where you can generate the output in PDF, XPS, DOCX, TIFF, and JPG formats. Now, as per the scope of this article, we are going to discuss the details of converting HTML to Doc. Now the first step is the installation, where you need to add the following details in pom.xml of the maven built type project.



Aspose.HTML for Cloud APIs are secured and require authentication. So please create a free subscription account on our cloud services via Aspose.Cloud dashboard using GitHub or Google account. Or, simply create a new Account and obtain your Client Credentials details.

Convert HTML to Word in Java

In this section, we are going to discuss the steps for converting HTML to Word format using Java code snippets.

  • First, create an object of WordsApi using a Client ID and Client Secret as parameters
  • Secondly, read the HTML file content from the local drive using the File object
  • Thirdly, create the UploadFileRequest instance while passing the File object as an argument
  • The next step is to call uploadFile(…) method so that the HTML file is uploaded to cloud storage
  • Now, create an object of GetDocumentWithFormatRequest(…) where we specify input HTML, output format as DOC, and the name of the resultant Doc file
  • Finally, call the method getDocumentWithFormat(…) to convert HTML to Doc and save the output in Cloud storage.
html to word doc

image 1:- HTML to Doc preview

Convert HTML to DOC using cURL Commands

Aspose.Cloud APIs can easily be accessed via cURL commands. But as a pre-requisite, first, we need to generate the JWT access token based on client credentials using the following command.

curl -v "" \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Please execute the following cURL command to convert HTML to DOC and save the output in cloud storage.

curl -v -X GET "" \
-H  "accept: application/octet-stream" \
-H  "Authorization: Bearer <JWT Token>"


In this article, we have learned the steps to develop HTML to DOC Converter using Java Cloud SDK. With fewer code lines, we have learned how to change HTML to DOC using Java code snippets as well as through the cURL commands. You may also consider exploring the APIs through Swagger UI within a web browser.

Should you have any related queries or you encounter any issues, please feel free to contact us via the free technical support forum.

We highly recommend going through the following articles to learn more about them: