This topic entails the process to convert a Word DOC to MHTML with NET REST API. We will employ Aspose.Words for .NET Cloud SDK for rendering a DOC to MHTML with C# Low Code API. Follow the steps given below in this article and try a working running sample C# REST API code.
Prerequisite
- Create an account and get API credentials
- Download Aspose.Words Cloud SDK for Dotnet to convert Word to MHTML
- Setup C# solution project with the above SDK
Steps to Convert Word to MHTML with NET 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 user credentials
- Set the input Word file and output MHTML file names
- Read the source Word DOC file using a FileStream
- Create the ConvertDocumentRequest instance using the FileStream and output file format
- Use the ConvertDocument method to convert Word DOC to MHTML using the ConvertDocumentRequest object
- Save the generated MHTML file on the local disk
The above mentioned steps explain the conversion of a file format from Word to MHTML with C# Low Code API. The process will kick off by setting the client secret/id in the Configuration object and creating an instance of the WordsApi class using the given configuration. In the subsequent steps, the source Word file is read into a FileStream and passed on to ConvertDocumentRequest instance for converting the input DOC to MHTML.
Code for Developing Word DOC to MHTML Converter with C# Low Code API
This sample code exhibits the process to convert DOC to MHTML with C# REST API. The ConvertDocumentRequest class instance is initialized with the input file byte stream and output file format along with the other options to configure the font location, the password to load the encrypted Word files, and encoding details while opening the input file. Finally, the ConvertDocument() method is used to transform the DOCX file to MHTML.
In this topic, we have focused on how to convert DOC file to MHTML with C# REST API. If you are looking to convert a Word document to MD file, refer to the article on how to Convert Word DOC to Markdown with NET REST API.