Skip to content
ComPDF
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

PDF Compare

With the PDF rotation tool, you can Compare your PDF file as you want. The following examples show how to upload a test PDF file and compare PDF using Java languages. Then, output the compare PDF file.

java
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);

// Create a task
// Create an example of a Compare task
CPDFCreateTaskResult result = client.createTask(CPDFDocumentEditorEnum.PDF_CONTENT_COMPARE);
//CPDFCreateTaskResult result = client.createTask(CPDFDocumentEditorEnum.PDF_COVER_COMPARE);

// Get a task id
String taskId = result.getTaskId();

// File handling parameter settings
CPDFOverlayComparisonParameter fileParameter = new CPDFOverlayComparisonParameter();
fileParameter.setInTransparency("0.5");
fileParameter.setNewTransparency("0.5");
fileParameter.setCoverType("0");
fileParameter.setInColor("#FBBDBF");
fileParameter.setNewColor("#93B9FD");

// Upload files
client.uploadFile(new File("test.pdf"), taskId, fileParameter);
client.uploadFile(new File("test1.pdf"), taskId, fileParameter);

// Execute task
client.executeTask(taskId);

// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);

Compare PDF content (Include text and images):

  • For one task, you must upload two PDF files. If isSaveTwo is set to "1", the processing result will be in a .zip file, which contains the comparison result files of the two PDFs.
  • For the same task, two PDF files must be uploaded. If isSaveTwo is set to "0", the processing result will be in a .pdf file, where the comparison results of the two files are combined into this file.

Needed Parameters

isSaveTwo: Specify whether to generate two output files during content comparison: 1 for yes, 0 for no (default value is 0).

imgCompare: Specify whether to enable image comparison: 1 for yes, 0 for no (default value is 1).

textCompare: Specify whether to enable text comparison: 1 for yes, 0 for no (default value is 1).

replaceColor: Define the color for the replaced content (default value is #93B9FD).

insertColor: Define the color for the inserted content (default value is #C0FFEC).

deleteColor: Define the color for the deleted content (default value is #FBBDBF).

Result:

File TypeDescription
.pdfResult file of overlay comparison.