Content Comparison


Quickly pinpoint changes by comparing two versions of a PDF file.


This can be done in ComPDFKit using CPDFCompareContent. The process of preparing documents and comparing them involves a few steps to specify how the comparison should happen.

Generating the Comparison Results


You can use CPDFCompareContent to generate the comparison results. First, initialize it with the two versions of a document to be compared, and then call the Compare function as argument:


CPDFDocument oldDocument = CPDFDocument.InitWithFilePath("***");
  CPDFDocument newDocument = CPDFDocument.InitWithFilePath("***");
  CPDFCompareContent compareContent = new CPDFCompareContent(oldDocument, newDocument);
  int pageCount = Math.Min(oldDocument.PageCount,newDocument.PageCount);
  for(int i=0;i<pageCount-1;i++)
      CPDFCompareResults compareResults = compareContent.Compare(i,i,CPDFCompareType.CPDFCompareTypeAll,true);


You can compare the different content types of the document by setting type. For example, using  CPDFCompareTypeText to compare text only or using CPDFCompareTypeAll to compare all content.

Changing the Highlight Colors


One of the most important steps of generating the comparison results is the ability to change the highlight colors, which makes it easier to see the differences between two versions of a document.


The highlight colors of both versions of a document can be changed using the SetReplaceColorSetInsertColor, and SetDeleteColor properties.