Free Support Forum - groupdocs.com

Compare method returns null using .NET

Hi.


I’m using trial version to evaluate some features. I downloaded example code and I’m tryng to compare two documents. When I invoke Compare() method, it returns always null.

What it means? Two documents are differents. This is the code:

Stream sourceStream = File.Open(Path.Combine(Common.sourcePath, Common.sourceFile), FileMode.Open, FileAccess.Read);
Stream targetStream = File.Open(Path.Combine(Common.targetPath, Common.targetFile), FileMode.Open, FileAccess.Read);

ComparisonSettings set = new ComparisonSettings();
set.DetailLevel = DetailLevel.Hight;

// Get instance of GroupDocs.Comparison.Comparer and call method Compare.
GroupDocs.Comparison.Comparer comparison = Common.getComparison();
ICompareResult result = comparison.Compare(sourceStream, targetStream, set);

// get result document as stream.
Stream stream = result.GetStream();

sourceStream.Close();
targetStream.Close();
stream.Close();

Thx

@daniele.busseda

We’d recommend you to download latest release of the API. We’ve made document comparison process a lot easier in it. Have a look at the migration notes. Below is the simplified code to compare two PDF files:

using (Comparer comparer = new Comparer(“source.pdf”))
{
    comparer.Add(“target.pdf”);
    comparer.Compare(“result.pdf”);
}

If you face any issue, you can share the problematic files with us along-with the exception details.