Skip to content
ComPDF
DemoSampleAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Overlay Comparison

To perform an overlay comparison, proceed as follows:

  1. Open the two documents being compared.

  2. Create the CPDFCompareDrawings object.

  3. Set the colour and other properties of the comparison.

  4. Call compareDrawings.getDocGenerate() to get the comparison results and save them to the document.

This example shows how to add an overlay comparison:

java
CPDFDocument baseDocument = new CPDFDocument();
baseDocument.open(rootDir + "/TestFiles/comparefile.pdf");
CPDFDocument comDocument = new CPDFDocument();
comDocument.open(rootDir + "/TestFiles/comparefile1.pdf");
printDividingLine();

CPDFCompareDrawings compareDrawings = baseDocument.createCompareDrawings(comDocument);
compareDrawings.setBlendMode(4);
compareDrawings.setColorCompare(Color.decode("#FBBDBF").getRGB());
compareDrawings.setColorCompared(Color.decode("#93B9FD").getRGB());
compareDrawings.setFillAlphaCompare(50);
compareDrawings.setFillAlphaCompared(50);
compareDrawings.compareContent();
CPDFDocument document = compareDrawings.getDocGenerate();
document.save(rootDir + "/out/compareTestOverlay.pdf", CPDFDocument.PDFDocumentSaveType.PDFDocumentSaveNoIncremental);