In this article we demonstrate how to Java REST API conversion of a Word DOC to MHTML using the Aspose.Words Cloud SDK for Java. Follow the steps below to run a working Java REST API sample that transforms a DOC file into MHTML.
Prerequisite
- Create an account and get API credentials
- Download the Aspose.Words Cloud SDK for Java to convert Word to MHTML
- Set up a Java project and add the SDK as a dependency
Steps to Convert Word to MHTML with Java REST API
- Set up the Client ID and Client Secret for the API to convert DOC to MHTML.
- Instantiate an object of the WordsApi class with the user credentials.
- Define the input Word file name and the desired output MHTML file name.
- Read the source Word DOC file into a FileInputStream.
- Create a ConvertDocumentRequest instance using the stream and specifying the output format.
- Call the ConvertDocument method to perform the conversion from DOC to MHTML.
- Save the generated MHTML file to the local disk.
The steps above outline the conversion process from Word to MHTML with Java REST API. First, configure the client ID/secret in the Configuration object and create a WordsApi instance. Then read the source DOC file into a stream, pass it to ConvertDocumentRequest, and invoke ConvertDocument to obtain the MHTML output, which you can write to disk.
Code for Developing Word DOC to MHTML Converter with Java REST API
The sample code shows how to convert DOC to MHTML with Java REST API. The ConvertDocumentRequest is initialized with the input file byte stream and the target format, along with optional settings such as font location, password for encrypted documents, and encoding. Finally, the ConvertDocument() method performs the transformation.
If you need to convert a Word document to another format, see the article on how to Convert Word DOC to Markdown with Java REST API.
Keywords: doc to MHTML with Java Low Code API; convert doc file to MHTML with Java REST API; convert a word doc to MHTML with NET REST API; word doc to MHTML converter with Java Low Code API; word to MHTML with NET REST API; from word to MHTML with Java Low Code API.