docx4j downloads
source code
We'd like to encourage you to use the docx4j source code in your IDE, so we put this option near the top.
- Fork https://github.com/plutext/docx4j [optional but recommended]
- git clone your fork, or git clone https://github.com/plutext/docx4j
- Import the Maven pom in your IDE. In Eclipse, that's File > Import > Maven > Existing Maven Projects.
maven pom
docx4j is in Maven Central: Select one and only one of:
- docx4j-JAXB-Internal (available for docx4j 8.x only),
- docx4j-JAXB-MOXy 11.5.0 or 8.3.11,
- docx4j-JAXB-ReferenceImpl 11.5.0 or 8.3.11,
Unless you are stuck on Java 8, we recommend our 11.5 (or 11.4) series.
Take note if upgrading: docx4j v11.5 uses Jakarta XML Binding API 4 .0 (and v11.4 uses Jakarta XML Binding API 3.0), as opposed to JAXB 2.x used in earlier versions (which import javax.xml.bind.*). Since v11.4 and v11.5 uses jakarta.xml.bind, rather than javax.xml.bind, if you have existing code which imports javax.xml.bind, you'll need to search/replace across your code base, replacing javax.xml.bind with jakarta.xml.bind. You'll also need to replace your JAXB jars (which Maven will do for you automatically; otherwise get them from the relevant zip file).
zip distribution for Java 11
Java 11 users can use docx4j-community-11.5.0.zip (or the earlier 8.x releases - see above)
You'll need:
zip distribution for Java 8
Java 8 users will want docx4j-community-8.3.11.zip
For convenience, that zip file includes the docx4j-JAXB-Internal jar. So if you are using Java 8, that is generally all you need.
If you want to use MOXy or the JAXB Reference Impl, instead you'll need:
Be sure to exclude the docx4j-JAXB-Internal jar!
Docs - Getting Started?
The zip distributions contain Docx4j_GettingStarted.pdf; Docx4j_GettingStarted can also be found in various formats on GitHub
Cheat sheet
Docx4j Code Generation
Download/install the Docx4j Helper AddIn for Microsoft Word to generate docx4j Java code from within Word, see the XML, plus more.
Or use the webapp (which also helps with pptx and xlsx).
Sample code
Sample code is not in Maven Central.
Zip files are available, for docx4j 11.5.0:
- docx4j: docx4j-samples-docx4j-11.5.0.zip
- pptx4j: docx4j-samples-pptx4j-11.5.0.zip
- xlsx4j: docx4j-samples-xls4j-11.5.0.zip
You can also find these in the respective sub-directories at https://github.com/plutext/docx4j/tree/docx4j-parent-11.5.0
For docx4j 8.3.11:
- docx4j: docx4j-samples-docx4j-8.3.11.zip
- pptx4j: docx4j-samples-pptx4j-8.3.11.zip
- xlsx4j: docx4j-samples-xlsx4j-8.3.11.zip
For docx to pdf conversion, docx4j 8.3.11 can use documents4j (and Microsoft Word, running locally or remotely). Zipped up sample code:
- for Word running locally: docx4j-samples-documents4j-local-8.3.11.zip
- for Word running remotely: docx4j-samples-documents4j-remote-8.3.11.zip
You can also find these in the respective sub-directories at https://github.com/plutext/docx4j
Docx4j properties
Sample properties file may be found at docx4j-samples-resources/src/main/resources/docx4j.properties
Logging
To see docx4j logs, you'll need a concrete logging implementation. Config files for log4j2 and logback may be found in the sample resources
For convenience, the sample zips include the deps necessary for those 2 logging implementations. Note that these differ between docx4j 8 and docx4j 11