Save comparison result in different format

On this page

GroupDocs.Comparison allows you to save output document in different formats.

To save output document in different format, follow these steps:

  1. Instantiate the Comparer object. Specify the source document path or stream.
  2. Call the add() method. Specify the target document path or stream.
  3. Call the compare() method. Specify the result document path with the required format.

The following code snippet shows how to save comparison result in different format:

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

try (Comparer comparer = new Comparer("source.txt")) {
    // Add target document
    comparer.add("target.txt");

    // Compare and save comparison result
    final Path resultPath = comparer.compare("result.pdf");
}
Warning
On Java 17 and later, start the JVM with --add-opens java.base/java.io=ALL-UNNAMED when saving a text comparison result to a file with a different extension. Without this flag the result file is written as plain text regardless of its extension.

See also

On this page

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.