本页内容
覆盖对比
进行覆盖对比的步骤如下:
打开对比的两个文档。
创建 CPDFCompareDrawings 对象。
设置对比的颜色等属性。
调用 compareDrawings.getDocGenerate() 获取对比结果并且保存到文档。
以下是覆盖对比的示例代码:
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);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15