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).

Java 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.

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/v1/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).

Java 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.

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/v1/process/pdf/coverCompare")
                .method("POST", body)
                .addHeader("x-api-key", "{{apiKey}}")
                .build();
        Response response = client.newCall(request).execute();
    }
}

Result:

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