DEV Community

E-iceblue Product Family
E-iceblue Product Family

Posted on

Compare Two Word documents and get the difference reports in Java

It is a time-consuming job when we need to analyzes two Word documents which look similar. Spire.Doc for Java offers a method of, "Author") to compare the word document and generate a report in track changes to make the difference clearly. As long as you have two separate Word documents, you can compare them in three lines of codes in Java applications.
Firstly, ensure that you are using Spire.Doc for Java V 3.8.8 or above and please check the sample word document as below:
Sample word

import com.spire.doc.Document;

public class CompareWordDocuments {

    public static void main(String[] args)throws Exception  {
        //Create a Document instance
        Document doc1 = new Document();
        //Load the first Word document

        //Create a Document instance
        Document doc2 = new Document();
        //Load the second Word document

        //Compare the two Word documents, "E-iceblue");

        //Save the result to file


After run the project,we will get the Word document as below:

Top comments (0)