With scConverter you can easily add document compare functionality to your application. scConverter will compare two documents, for example two PDF files, and generate a visual comparison result. You can define the colors to use for both new and old document. There are two functions available for comparing files:
In this small tutorial you will find out how you can use these two functions create a PDF comparison.
In the first sample code for comparing two pdf files, we will use red color for the old file and blue color for the new file. The resulting PDF file will draw old deleted using red color, and new additions will be drawn using blue color. Unchanged content will be drawn using black color.
scconverter.SetSerialNumber("serial number"); scconverter.PDFWriteFormat = 0; //Output standard editable PDF scconverter.SaveCompareResult( "compare_revA.pdf", "compare_revB.pdf", "output1.pdf", "PDF", 0x000000FF, 0x00FF0000, 200 );
In this example we use 200 DPI for the resolution, but you can use any DPI value you want (limited by memory only). Please note that higher values give higher quality but will also consume more memory. The resulting output file will also be larger.
The PDF file created by our code will then look the following:
If the document extents are large it may be difficult to see the changes immediately. We can instead use the other function named SaveCompareResultEx, which let us change the color for the content that are unchanged. Let us change this color to a lighter gray color and generate the output PDF again:
scconverter.SaveCompareResultEx( "compare_revA.pdf", "compare_revB.pdf", "output2.pdf", "PDF", 0x000000FF, 0x00FF0000, 0x00D0D0D0, 200);
This code will create a output PDF file named "output2.pdf" as shown below:
It may still be difficult to see the changes due to the display scaling in Adobe Acrobat. We can change the color for unchanged content to white, this will force that only changed content will be displayed in our PDF file. Change the code to the following:
scconverter.SaveCompareResultEx( "compare_revA.pdf", "compare_revB.pdf", "output3.pdf", "PDF", 0x000000FF, 0x00FF0000, 0x00FFFFFF, 200);
This code will create a output PDF file named "output3.pdf" as shown below:
So far, we've only mentioned that you can compare PDF and DWF files, but you can use scConverter to compare files of any file format supported by the component. You may for example compare TIFF files, PLT files, CGM files, Gerber files, PNG files and so on.