Open Source Java API for Word DOCX Documents

Create, Read, Edit and Convert Microsoft Word DOCX files, add text & tables via Java Libray.

 

DOCX4J is JAXB-based open source(Apache v2) library for manipulating Microsoft Office file formats. It provides the functionality to read, write, edit & and save Microsoft Word 2007 DOCX file format.  

DOCX4J is similar to Microsoft's OpenXML SDK, but for Java. It uses JAXB to create the in-memory object representation. Using the API you can generate Mircosoft Office documents, edit them, format the text & paragraphs, insert tables & images and manage other form elements and much more. Basically, its emphasis is on power, if the format supports it you can do it using the API.

Getting Started with DOCX4J

First of all, you need to have the Java Development Kit (JDK) installed on your system. Referencing DOCX4J in your Maven-based Java project is even simpler. All you need is to add the following dependency in your pom.xml and let your IDE fetch and reference the DOCX4J Jar files.

DOCX4J Maven Dependency

<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>

Add Paragraph, Image & Table to Word Documents

DOCX4J allows the developers to add paragraphs & images to Word documents. The API also provides the feature to add tables to DOCX document while making it possible to create simple and nested tables with user-defined data.

Generate & Edit Word Documents using Java API

DOCX4J enables the software programmers to create new Word Documents in DOCX file format. Developers can also load an existing Microsoft Word DOCX file to edit it according to their application needs. It allows to add new paragraphs, insert text, apply text alignment & borders, change text styling and more.

Extract Text from DOCX

DOCX4J provides the specialized class to extract data from Microsoft Word DOCX documents with just a few lines of code. In the same way, it can also extract headings, footnotes, table data and so on from a Word file.