Compare of Variables and Document properties

On this page


GroupDocs.Comparison allows you to compare various properties of a Word document such as Variable, Built, and Custom properties.

Use the following methods of the CompareOptions class to enable comparison functions for document properties:

To activate compare document properties, 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. Call the setCompareVariableProperty() method to compare the variable properties and/or the setCompareDocumentProperty() for built and custom properties.
  4. Call the compare() method. Specify the CompareOptions object from the previous step.

The following code snippet shows how activate comparison of the variable, Bbuilt and custom properties:

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 options = new CompareOptions();

    // to activate comparison of variable properties
    options.setCompareVariableProperty(true); 

    // to activate the comparison of built and custom properties
    options.setCompareDocumentProperty(true); 

    final Path resultPath = comparer.compare("result.docx", options);
}

The result is as follows:

On this page