Nowadays, Markdown (MD) format is widely opted to write online articles, blogs, and documentation. However, its syntax becomes difficult to remember and write in the case of large-sized documents. To make things easier, you can write content in MS Word and then convert DOC file to Markdown. To perform this conversion programmatically, this article covers how to convert DOC to Markdown (.md) in Java.
- Java DOC to Markdown Converter Library
- Convert a DOC to Markdown in Java
- Customize DOC to Markdown Conversion
Java DOC to Markdown Converter - Free Download
To convert DOC files to Markdown format, we will use Aspose.Words for Java. The said API allows you to create and manipulate Word documents from within Java applications. Also, it provides a high-quality document converter to convert DOC documents to other formats. You can download the API’s JAR or install it using the following Maven configurations.
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>https://repository.aspose.com/repo/</url> </repository> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-words</artifactId> <version>21.11</version> <type>pom</type> </dependency>
Convert DOC to Markdown in Java
The following are the steps to convert a DOC file to Markdown in Java.
- Load the DOC file using Document class.
- Convert DOC file to Markdown format using Document.save(string) method.
The following code sample shows how to convert a DOC file to Markdown (MD) using Java.
Java DOC to Markdown - Customization
You can also change the default behavior of the API for DOC to Markdown conversion. For example, you can set the alignment of the content in the tables, specify a folder to keep images, and so on. The following are the steps to set different options in Java DOC to Markdown conversion.
- Load the DOC document using Document class.
- Create an object of MarkdownSaveOptions class.
- Set desired options such as MarkdownSaveOptions.setImagesFolder(string).
- Save DOC document as Markdown using Document.save(string, MarkdownSaveOptions) method.
The following code sample shows how to customize DOC to Markdown conversion using Java.
DOC to Markdown Java Converter - Get a Free License
You can use Aspose.Words for Java without evaluation limitations using a temporary license.
In this article, you have learned how to convert DOC files to Markdown (.md) programmatically in Java. Moreover, you have seen how to modify DOC to Markdown conversion using different options. You can also explore other features offered by Aspose.Words for Java using the documentation. In addition, you can feel free to ask your questions via our forum.