Compare bookmarks in Word documents

On this page


GroupDocs.Comparison allows you to compare bookmarks in the Word documents.

To compare bookmarks in the Word documents, follow these steps:

  1. Instantiate the Comparer object. Specify the source file path or stream.
  2. Call the add() method. Specify the target file path or stream.
  3. Instantiate the CompareOptions object. Set the CompareBookmarks property to true.
  4. Call the compare() method. Specify the CompareOptions object from the previous step.

The following code snippet shows how to demonstrate how to compare bookmarks:

import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.options.CompareOptions;
import java.nio.file.Path;
// ...

try (Comparer comparer = new Comparer("source.docx")) {
    comparer.add("target.docx");

    CompareOptions compareOptions = new CompareOptions();
    compareOptions.setCompareBookmarks(true);
    final Path resultPath = comparer.compare("result.docx", compareOptions);
}

The result of compared bookmarks is as follows:

On this page