This short tutorial shows you how to convert DOCX to MD with Java REST API in the cloud. In order to export DOCX to MD format, we’re using Aspose.Words for Java Cloud SDK. If you require DOCX to MD Conversion in Java Low Code API then this can be accomplished by using the following sample code and simple steps.
Prerequisite
- Create account and get API credentials
- Download Aspose.Words Cloud SDK for Java
- Setup Java project with the above SDK
Steps to Convert DOCX to MD in Java REST API
- Set Client ID and Client Secret for the API
- Create an instance of WordsAPI class with client credentials
- Specify input and output files
- Read input DOCX file and upload to cloud storage
- Create an instance of WordsAPI with input and output file formats
- Call convertDocument method to Convert DOCX to MD using REST API
- Save the output MD file on local disk
Code for DOCX to MD Conversion in Java Low Code API
String ClientID = Client.getID(); //replace Client.getID() with your own client ID here | |
String ClientSecret = Client.getSecret(); //replace3 Client.getSecret() with your own client secret here | |
String APIBaseUrl="https://api.aspose.cloud"; | |
String Local_Path = "C:/Temp/"; | |
try { | |
//Create API client with credentials | |
ApiClient apiClient = new ApiClient(ClientID, ClientSecret, APIBaseUrl); | |
//Create SDK object | |
WordsApi wordsApi = new WordsApi(apiClient); | |
String inputFile = "DOCXToMD.docx"; | |
String outputFile = "DOCXToMD.md"; | |
String outputFormat = "md"; | |
//Read input file to bytes array | |
byte[] inputFileData = Files.readAllBytes(Paths.get(Local_Path + inputFile).toAbsolutePath()); | |
//create conversion request object with input and output files | |
ConvertDocumentRequest convertDocumentRequest = new ConvertDocumentRequest(inputFileData, outputFormat, null, null, null, null, null, null, null); | |
//convert the input file to output format | |
byte[] outputFileData = wordsApi.convertDocument(convertDocumentRequest); | |
//save the output file from the bytes array | |
FileOutputStream fileOutputStream = new FileOutputStream(Local_Path + outputFile); | |
fileOutputStream.write(outputFileData); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} |
The code snippet given on this page assists you to convert DOCX to MD with Java REST API. You merely have to upload DOCX file with the help of the Aspose.Words REST API SDK for Java and download output MD file to save it locally by using Aspose conversion API online.
The above DOCX to MD Conversion could be used with any no code or low code apps on any device or computer.
A related feature might also be helpful to you: How to Convert DOCX to TIFF with Java REST API