Creating an application to compare changes made to documents or images of documents can be an unnecessary burden on development time...unless of course, you simply use our Document Compare SDK! LEADTOOLS includes an interactive comparison navigator that allows users to step through insertions, deletions, and edits to easily compare documents as well as images of documents.
Leveraging our unbeatable AI-powered OCR engine, the Document Compare tool takes your uploaded files and highlights the differences between them. From PDF to DOCX to JPEG to TIF, LEADTOOLS supports over 165+ document and image formats so you can compare any input type that you need. And, like all of LEADTOOLS, this OEM-ready document comparison solution can be easily integrated into both new and existing applications with minimal code changes.
More than just a UI component, the Document Compare SDK is also able to generate a report for the text compare as well as create a combined image for the raster compare to highlight the differences. In this post, we'll highlight some of our document and image comparison features as well as some use-cases from developers who have integrated our LEADTOOLS Document Compare SDK into their applications!
Compare Text Changes Between Documents
Our document compare libraries quickly assess the text of two documents to determine the content changes between them and can even create a detailed report that shows every addition and deletion from the document. Reference our Compare Document Contents tutorial to see exactly how to implement this into your application.
The code sample below shows the primary function of the tutorial:
private void CompareDocuments()
{
if (_virtualDocument.Pages.Count == 0 || _virtualDocument2.Pages.Count == 0)
{
MessageBox.Show("You need a document in each viewer before you can use the comparison feature");
return;
}
var docList = new List()
{
_virtualDocument,
_virtualDocument2
}
var comparer = new DocumentComparer();
_documentDifference = comparer.CompareDocument(docList);
if (!_documentDifference.HasDeletions() && !_documentDifference.HasInsertions())
{
MessageBox.Show("These documents are identical.");
return;
}
_documentViewer.BeginUpdate();
_documentViewer2.BeginUpdate();
if (_documentDifference.HasDeletions())
{
_deletions = _documentDifference.GetDeletions();
AnnotateDeletions();
}
if (_documentDifference.HasInsertions())
{
_insertions = _documentDifference.GetInsertions();
AnnotateInsertions();
}
_documentViewer.EndUpdate();
_documentViewer2.EndUpdate();
}
Compare Entire Page Changes
You can also compare entire pages of a document instead of just the text. Visualize files side-by-side or layer the pages to compare documents with both text and images to see any changes or differences. We have a guide to help you implement this as well, just check out our Compare Document Pages tutorial.
Compare Images
Use our Document Compare SDK to overlay images so that you can accurately compare any differences. Advanced implementation also allows for adjusting the size and position of images in order to compare images in varying states and sizes. Check out our Compare Images tutorial for more information on how to implement image comparison.
Document page comparison and image comparison use the same portion of code:
private void CompareDocuments(bool flag)
{
if(!flag)
{
BringTwoViewerToFront();
return;
}
RasterImage image = RasterImage.Create(1, 1, 1, 1, RasterColor.Black);
_combinedViewer.BeginUpdate();
//Get ammount of pages
var pageCount = _documentViewer.PageCount;
if (pageCount < _documentViewer2.PageCount)
{
pageCount = _documentViewer2.PageCount;
}
for (int i = 0; i < pageCount; i++)
{
var comparer = new DocumentComparer();
IList pages = new List()
{
_documentViewer.Document.Pages[i],
_documentViewer2.Document.Pages[i]
}
var combineResult = comparer.CompareRasterPage(pages, new RasterCompareOptions());
if (i == 0)
{
image = new RasterImage(combineResult);
}
else
{
image.AddPage(combineResult);
}
}
_combinedViewer.Image = image;
_combinedViewer.EndUpdate();
BringSingleViewerToFront();
}
Dare to Compare: Use-Cases for Document Comparison
Curious the numerous ways you can use our Document Compare features within your application? Here are a few scenarios that our customers use LEADTOOLS for:
Start Comparing Your Documents Today!
Get started comparing your files right away using our Document Compare Demo. If you're ready to level-up your application development and want to see everything else LEADTOOLS has to offer, download our FREE Evaluation SDK. With the evaluation, you gain access to our full collection of libraries, the source code for all our demo applications, free technical support via live chat and email, as well as our extensive documentation and tutorials - like the ones mentioned in this blog: