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
isSaveTwois 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
isSaveTwois set to "0", the processing result will be a .pdf file (the comparison results of the two files will be integrated into this file).
{
"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 --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"'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 Type | Description |
|---|---|
| .pdf or .zip | Result 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.
{
"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 --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"'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 Parameter | Data Type | Description |
|---|---|---|
| code | String | HTTP request status, "200" indicates success |
| message | String | Request message |
| data | Object | Return result |
| +taskId | String | Task ID |
| +taskFileNum | int | Number of files processed in the task |
| +taskSuccessNum | int | Number of files successfully processed in the task |
| +taskFailNum | int | Number of files failed in the task |
| +taskStatus | String | Task status |
| +assetTypeId | int | Used asset type ID |
| +taskCost | int | Task cost |
| +taskTime | int | Task duration |
| +sourceType | String | Original format |
| +targetType | String | Target format |
| +fileInfoDTOList | Array | Task file information |
| ++fileKey | String | File key |
| ++taskId | String | Task ID |
| ++fileName | String | Original file name |
| ++downFileName | String | Download file name |
| ++fileUrl | String | Original file URL |
| ++downloadUrl | String | Processed result file download URL |
| ++sourceType | String | Original format |
| ++targetType | String | Target format |
| ++fileSize | int | File size |
| ++convertSize | int | Processed result file size |
| ++convertTime | int | Processing time |
| ++status | String | File processing status |
| ++failureCode | String | File processing failure error code |
| ++failureReason | String | File processing failure description |
| ++fileParameter | String | Processing parameter |
Response Example:
"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 Type | Description |
|---|---|
| Result file after document comparison (overlay comparison) |
Asynchronous Request
If you need to use the file asynchronous processing flow, please read the Asynchronous Request Instructions.