Word to HTML Java

To embed the content of Word documents into your applications, you might need to perform the conversion. The most widely opted conversions in such cases are Word to HTML or an image. Following that, this article covers how to convert Word DOCX or DOC files to HTML using Java. Also, we’ll discuss how to keep resource files in a separate folder.

Java API for Word to HTML Conversion

For DOCX DOC to HTML conversion, we will use Aspose.Words for Java. It provides the free, high-quality and high-speed Word to HTML conversion solution. You can convert as many Word documents to HTML as you want. You can either download the API or install it from Maven.

<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>22.10</version>
    <type>pom</type>
</dependency>

Convert a Word Document to HTML in Java

To convert a Word document to HTML, you only need to load the document and save it as an HTML file. The following are the steps to convert a Word DOCX file to HTML using Java.

The following code sample shows how to convert a Word document to HTML using Java.

Specify Resource Folder in Word to HTML Conversion

You can also configure the API to save the resource files in a separate folder. Moreover, you can keep fonts and images separately in different folders. The following are the steps to specify the resource folder.

The following code sample keeps resource files in a separate folder in Word to HTML conversion.

You can read more about working with resource folders in Word to HTML conversion.

Free Word to HTML Converter

You can a free temporary license and convert Word documents to HTML without any limitations.

Conclusion

In this article, you have learned how to convert Word DOCX or DOC files to HTML programmatically using Java. In addition to this, you have seen how to store resource files separately in Word to HTML conversion. Besides, you can read more about Aspose.Words for Java using the documentation. Furthermore, you can share your queries with us on our forum.

See Also