Learn how to Compare Word Documents and Highlight Differences using Java
The following topics are covered here:
- Compare Two Word Documents using Java
- Word Documents Comparison with Compare Options using Java
- Compare Bookmarks in Word Documents
Learn how to Compare Word Documents and Highlight Differences using Java
The following topics are covered here:
// initialize comparer | |
Comparer comparer = new Comparer("C:\\Files\\source.docx"); | |
// add target file | |
comparer.add("C:\\Files\\target.docx"); | |
// define compare options | |
CompareOptions compareOptions = new CompareOptions(); | |
compareOptions.setCompareBookmarks(true); | |
// compare and save compare results | |
comparer.compare("C:\\Files\\result.docx", compareOptions); |
// initialize comparer | |
Comparer comparer = new Comparer("C:\\Files\\source.docx"); | |
// add target file | |
comparer.add("C:\\Files\\target.docx"); | |
// compare and save compare results | |
comparer.compare("C:\\Files\\result.docx"); |
// initialize comparer | |
Comparer comparer = new Comparer("C:\\Files\\source.docx"); | |
// add target file | |
comparer.add("C:\\Files\\target.docx"); | |
// compare | |
final Path resultPath = comparer.compare(); | |
// get changes | |
ChangeInfo[] changes = comparer.getChanges(); | |
System.out.println("Count of changes: " + changes.length); | |
for (ChangeInfo change : changes) { | |
System.out.printf("Change Type: %d, Text: %s%n", change.getType(), change.getText()); | |
} |