GroupDocs.Comparison for .NET – C# Diff Library for Comparing Text Files

GroupDocs.Comparison for .NetThe GroupDocs.Comparison for .NET is a C# diff library which allows you to merge and compare different versions of a text file and display differences between them through a diff view UI. The library is smart enough to detect both context and style changes. It can be used to compare almost all common text file types, including: PDF, Microsoft Word (DOC, DOCX), Excel (XLS, XLSX), PowerPoint (PPT, PPTX), plain text files (TXT), OpenDocument (ODT) and HTML.

The library merges uploaded text files and then displays diffs between them with a redline view approach – similar to Microsoft Word’s change tracking view. Merged documents are rendered trough the web UI with pure HTML5, JavaScript and CSS. This allows end users to see differences between the compared text files using any modern web-browser.

GroupDocs.Comparison is a 100% independent C# diff library – there is no need to install Microsoft Office, Adobe Acrobat or any other software either on server or client side. Thanks to the flexible API, you can use GroupDocs.Comparison with your own UI or in the console and any types of web, mobile and desktop apps.

We’ve already presented the library to our regular readers. Since then the library has seen a number of exciting improvements. Today, we’d like to discuss them in detail.

Support for Streams

The latest version of the diff library was enhanced with an ability to read text files from streams. Now you can easily connect it to your service or implement a complex project with documents hosted anywhere you need. Stream initialization works the following way:

const string sourceFileName = "Tables.Source.docx";
const string targetFileName = "Tables.Target.docx";

using (var sourceStream = System.IO.File.OpenRead(Server.MapPath("~/App_Data/" + sourceFileName)))
using (var targetStream = System.IO.File.OpenRead(Server.MapPath("~/App_Data/" + targetFileName)))
        .SourceFileName(sourceFileName, sourceStream)
        .TargetFileName(targetFileName, targetStream);

Flexible API for Easy Integration Into Your Workflow

Although the diff view UI that comes with the library is 100% customizable, you can use the flexible API to build your own UI from scratch, or even use the library without the UI and compare documents on the server-side:

var service = new ComparisonService();

var changes = service.Compare();

Diff Text Styles

In addition to context differences, GroupDocs.Comparison can now identify changes in text styles, including bold, italic, underline, strike-trough, font changes, etc.

GroupDocs.Comparison Diff UI - Compare Text Styles

Accept and Reject Changes in Word Files

Differences found between Word (DOC, DOCX) files can be accepted or rejected right in a web UI and the result can be then exported to a final document in DOC/DOCX format.

GroupDocs' C# Diff Library - Accepting and Rejecting Changes

Merge & Compare Up to 3 Word (DOC, DOCX) Files

The library allows you to compare up to 3 versions of a Word file and generate a merged results file. You can also see which diffs came from what version of the file.

Send Result Documents to Streams

Now you can send merged documents and the diff details to streams, without having to write these directly to an output file.

//Optionally the redline result can be saved to stream
var memoryStream = new MemoryStream();

Diff Summary Tumbler

In case you don’t need a summary with a list of all differences to be included in the resulting file, you can now disable this feature easily:

//Disable summary page in the redline file

Enhanced Sample Project in C#

We’ve updated our demo written in C# to reflect the latest features and help you get started with the diff library quickly. Please feel free to download the demo from this page.


For more details on the diff library, please visit its homepage. Also, download a free evaluation copy and a demo. If you’d like to test the library without any functional restrictions, please contact sales for a free 30-day license. We also offer free deployment support, so please don’t hesitate to contact us – we’ll be happy to help.

Share on FacebookTweet about this on TwitterShare on LinkedIn