Edit Word DOCX using Java

You can programmatically edit all the Word processing document formats such as DOC, DOCX, or DOTM easily. As a Java developer, you can edit Word documents in your Java applications. In this article, you will learn how to edit word documents using Java.

The following topics are discussed/covered in this article:

Java API for Editing Word Documents

For editing DOCX files, I will be using GroupDocs.Editor for Java API. It allows you to programmatically edit Word processing documents, Excel sheets, or documents of other supported formats. The API enables you to load documents and convert them into HTML. It provides HTML to external UI for editing and then save HTML to the original document after manipulation.

You can download the JAR of the API or just add the following pom.xml configuration in your Maven-based Java applications to try the below-mentioned code examples.

	<name>GroupDocs Java API</name>

Edit Word Documents using Java

You can easily edit Word documents programmatically by following the simple steps mentioned below:

The following code sample shows how to edit DOCX files using Java.

Edit Word Documents using Java

Edit Word Documents using Java

The WordprocessingLoadOptions class provides various options for loading Word documents like DOC, DOCX, RTF, ODT, etc. into the Editor class.

  • The setPassword method allows specifying the password for opening the password-protected documents.

The Editor class is the main class that provides methods for loading, editing, and saving documents of all supportable formats. 

The WordProcesingEditOptions class enables you to specify custom options for opening the Word processing documents to edit.

  • The setEnabledLanguageInformation method specifies whether language information is exported to the HTML markup in a form of ‘lang’ HTML attributes.
  • The setEnablePagination method allows to enable or disable pagination in the resultant HTML document.

The EditableDocument class internally stores the document and provides methods for generating HTML markup and producing resources.

The WordProcessingSaveOptions class provides custom options for generating and saving Word documents after editing.

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.


In this article, you have learned how to edit Word documents using Java. You can learn more about GroupDocs.Editor for Java API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also