Skip to content

Document comparison Tool Guide

Content Comparison Tool Guide

Note:Before learning how to use different functions, we recommend that read the Request Workflow to know a basic PDF processing process. When using different functions, you can set their own special parameters when uploading files. Other basic steps are consistent.

Content comparison, also called side-by-side comparison, includes text and images in PDF content comparison:

  • In the same task, you must upload two PDF files. If isSaveTwo is set to "1", the processing result will be a .zip file containing two PDF comparison result files.
  • In the same task, you must upload two PDF files. If isSaveTwo is set to "0", the processing result will be a .pdf file (the comparison results of the two files will be integrated into this file).
java
{
    "isSaveTwo": "0",
    "imgCompare": "1",
    "textCompare": "1",
    "replaceColor": "#93B9FD",
    "insertColor": "#C0FFEC",
    "deleteColor": "#FBBDBF"
}

Required Parameters:

isSaveTwo: Whether to output two files during content comparison (1: Yes; 0: No). Default: 0.

imgCompare: Whether to use image comparison (1: Yes; 0: No). Default: 1.

textCompare: Whether to use text comparison (1: Yes; 0: No). Default: 1.

replaceColor: Color for replaced content (default: #93B9FD).

insertColor: Color for inserted content (default: #C0FFEC).

deleteColor: Color for deleted content (default: #FBBDBF).

Request Example:

Replace apiKey with the publicKey obtained from the dashboard, file with the file you want to convert, and language with your preferred interface error prompt language type.

curl
curl --location --request POST 'https://api-server.compdf.com/server/v2/process/pdf/contentCompare' \
--header 'x-api-key: apiKey' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"file1"' \
--form 'file=@"file2"' \
--form 'password="" \
--form 'parameter="{ \"imgCompare\": \"1\", \"isSaveTwo\": \"0\", \"textCompare\": \"1\", \"replaceColor\": \"#FF0000\", \"insertColor\": \"#FBBDBF\", \"deleteColor\":\"#93B9FD\" }"' \
--form 'language="1"'
java
import java.io.*;
import okhttp3.*;

public class Main {
    public static void main(String[] args) throws IOException {
        File firstFile = new File("first.pdf");  
        File secondFile = new File("second.pdf");     
        OkHttpClient client = new OkHttpClient().newBuilder().build();
        RequestBody body = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("{{file}}", firstFile.getName(),
                        RequestBody.create(MediaType.parse("application/octet-stream"), 
                        firstFile)
                .addFormDataPart("{{file}}", secondFile.getName(),
                        RequestBody.create(MediaType.parse("application/octet-stream"), 
                        secondFile)
                .addFormDataPart("language", "{{language}}") 
                .addFormDataPart("password", "")
                .addFormDataPart("parameter", "{ " +
                        "\"imgCompare\": \"1\", " +
                        "\"isSaveTwo\": \"0\", " +
                        "\"textCompare\": \"1\", " +
                        "\"replaceColor\": \"#FF0000\", " +
                        "\"insertColor\": \"#FBBDBF\", " +
                        "\"deleteColor\":\"#93B9FD\" " +
                        "}")
                .build();

        Request request = new Request.Builder()
                .url("https://api-server.compdf.com/server/v2/process/pdf/contentCompare")
                .method("POST", body)
                .addHeader("x-api-key", "{{apiKey}}")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Result:

File TypeDescription
.pdf or .zipResult file after document comparison (content comparison)

Overlay Comparison Tool Guide

Note:Before learning how to use different functions, we recommend that read the Request Workflow to know a basic PDF processing process. When using different functions, you can set their own special parameters when uploading files. Other basic steps are consistent.

PDF document overlay comparison (also called overlay comparison):

  • In the same task, you must upload two files.
java
{
    "inTransparency": "0.5",
    "newTransparency": "0.5",
    "coverType": "0",
    "inColor": "#FBBDBF",
    "newColor": "#93B9FD"
}

Required Parameters:

inTransparency: Transparency of the old file (0–1, default: 0.5).

newTransparency: Transparency of the new file (0–1, default: 0.5).

coverType: Blending mode (default: 0, where 0 represents Normal). Options: 0: Normal, 1: Multiply, 2: Screen, 3: Overlay, 4: Darken, 5: Lighten, 6: ColorDodge, 7: ColorBurn, 8: HardLight, 9: SoftLight, 10: Difference, 11: Exclusion, 12: Hue, 13: Saturation, 14: Colour, 15: Luminosity.

inColor: Old file color (default: #FBBDBF).

newColor: New file color (default: #93B9FD).

Request Example:

Replace apiKey with the publicKey obtained from the dashboard, file with the file you want to convert, and language with your preferred interface error prompt language type.

curl
curl --location --request POST 'https://api-server.compdf.com/server/v2/process/pdf/coverCompare' \
--header 'x-api-key: apiKey' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"file1"' \
--form 'file=@"file2"' \
--form 'password="" \
--form 'parameter="{ \"inTransparency\":\"0.5\", \"newTransparency\":\"0.5\", \"coverType\":\"0\", \"inColor\":\"#FBBDBF\", \"newColor\":\"#93B9FD\"}"' \
--form 'language="1"'
java
import java.io.*;
import okhttp3.*;

public class Main {
    public static void main(String[] args) throws IOException {
        File firstFile = new File("first.pdf");  
        File secondFile = new File("second.pdf");     
        OkHttpClient client = new OkHttpClient().newBuilder().build();
        RequestBody body = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("{{file}}", firstFile.getName(),
                        RequestBody.create(MediaType.parse("application/octet-stream"), 
                        firstFile)
                .addFormDataPart("{{file}}", secondFile.getName(),
                        RequestBody.create(MediaType.parse("application/octet-stream"), 
                        secondFile)
                .addFormDataPart("language", "{{language}}") 
                .addFormDataPart("password", "")
                .addFormDataPart("parameter", "{ \"inTransparency\":\"0.5\", \"newTransparency\":\"0.5\", \"coverType\":\"0\", \"inColor\":\"#FBBDBF\", \"newColor\":\"#93B9FD\"}")
                .build();

        Request request = new Request.Builder()
                .url("https://api-server.compdf.com/server/v2/process/pdf/coverCompare")
                .method("POST", body)
                .addHeader("x-api-key", "{{apiKey}}")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Response Information:

A successful request returns an HTTP 200 OK status code and a JSON response body showing the order details.

Response type:application/json

Response ParameterData TypeDescription
codeStringHTTP request status, "200" indicates success
messageStringRequest message
dataObjectReturn result
+taskIdStringTask ID
+taskFileNumintNumber of files processed in the task
+taskSuccessNumintNumber of files successfully processed in the task
+taskFailNumintNumber of files failed in the task
+taskStatusStringTask status
+assetTypeIdintUsed asset type ID
+taskCostintTask cost
+taskTimeintTask duration
+sourceTypeStringOriginal format
+targetTypeStringTarget format
+fileInfoDTOListArrayTask file information
++fileKeyStringFile key
++taskIdStringTask ID
++fileNameStringOriginal file name
++downFileNameStringDownload file name
++fileUrlStringOriginal file URL
++downloadUrlStringProcessed result file download URL
++sourceTypeStringOriginal format
++targetTypeStringTarget format
++fileSizeintFile size
++convertSizeintProcessed result file size
++convertTimeintProcessing time
++statusStringFile processing status
++failureCodeStringFile processing failure error code
++failureReasonStringFile processing failure description
++fileParameterStringProcessing parameter

Response Example:

json
"code": "200",
"msg": "success",
"data": {
    "taskId": "f416dbcf-0c10-4f93-ab9e-a835c1f5dba1",
    "taskFileNum": 1,
    "taskSuccessNum": 1,
    "taskFailNum": 0,
    "taskStatus": "<taskStatus>",
    "assetTypeId": 0,
    "taskCost": 1,
    "taskTime": 1,
    "sourceType": "<sourceType>",
    "targetType": "<targetType>",
    "fileInfoDTOList": [
      {
        "fileKey": "<fileKey>",
        "taskId": "<taskId>",
        "fileName": "<fileName>",
        "downFileName": "<downFileName>",
        "fileUrl": "<fileUrl>",
        "downloadUrl": "<downloadUrl>",
        "sourceType": "<sourceType>",
        "targetType": "<targetType>",
        "fileSize": 24475,
        "convertSize": 6922,
        "convertTime": 8,
        "status": "<status>",
        "failureCode": "",
        "failureReason": "",
        "fileParameter": "<fileParameter>"
      }
    ]
}

Result:

File TypeDescription
.pdfResult file after document comparison (overlay comparison)

Asynchronous Request

If you need to use the file asynchronous processing flow, please read the Asynchronous Request Instructions.