PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Comparing the content of two versions of PDF files, including text and images, enables the identification of deleted, added, and replaced content. Displaying the differences in a list format supports the ability to click and navigate to the specific change points within the PDF documents.
The steps to perform content comparison are as follows:
Open the two documents for comparison.
Create a content comparison object.
Compare the specified pages.
Retrieve the results of the content comparison.
This example shows how to perform content comparison:
CPDFDocument document = CPDFDocument.InitWithFilePath("File1.pdf");
CPDFDocument dewDocument = CPDFDocument.InitWithFilePath("File2.pdf");
CPDFCompareContent compareContent = new CPDFCompareContent(document, dewDocument);
int pageCount = Math.Min(document.PageCount, dewDocument.PageCount);
for (int i = 0; i < pageCount; i++)
{
Console.WriteLine("Page: {0}", i);
CPDFCompareResults compareResults = compareContent.Compare(i, i, CPDFCompareType.CPDFCompareTypeAll, true);
Console.WriteLine("Replace count: {0}", compareResults.ReplaceCount);
Console.WriteLine("TextResults count: {0}", compareResults.TextResults.Count);
Console.WriteLine("Delete count: {0}", compareResults.DeleteCount);
Console.WriteLine("Insert count: {0}", compareResults.InsertCount);
}type. For example, using CPDFCompareTypeText will only compare text, while using CPDFCompareTypeAll will compare all content.SetReplaceColor, SetInsertColor, and SetDeleteColor properties.