In this brief tutorial, we will learn how to convert Word to Markdown using Java. Markdown files are popularly used to create web pages and articles over the internet. You may create a document as a DOC or DOCX file and then export it with Word to Markdown converter using Java in any operating system like MS Windows, macOS, or Linux.
Steps to Convert Word to Markdown using Java
- Add reference to Aspose.Words JAR file using Maven repository
- Instantiate the Document class object to load source document
- Using MarkdownSaveOptions class, set different properties for the markdown file
- Save the generated output file in markdown format
In above steps, the input Word document is first loaded and then different properties exposed by MarkdownSaveOptions class are set. For instance, you can specify preferences for the markdown file like encoding, memory optimization or the header footer etc. Through this process, you can easily convert DOCX to MD using Java.
Code to Convert DOCX to Markdown using Java
In this code snippet, an object of Document class is initialized for loading the source Word document. Different characteristics for the output file are also set so that the encoding, headers footers are specified to get required markdown file. You can use this feature to convert DOCX to Markdown using Java in your application.
In this article, we have learned how to convert DOC to MD using Java. However, if you are interested to explore Word to HTML conversion, please refer to the article on how to convert DOCX to HTML using Java.