Intelligent Document Extraction 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.
Intelligent Document Extraction:
{
"keys": ["Title"],
"tableHandles": ["Invoice Number"],
"extractType": "0"
}
Required Parameters:
keys
: Text, e.g., ["Title"].
tableHandles
: Table headers, e.g., ["Invoice Number"]
extractType
: Full-text extraction (0: Default full text, 1: All text, 2: All tables)
Java Example:
You need to replace apiKey with the publicKey obtained from the console, file with the file you want to convert, and language with the desired interface error prompt language type.
import java.io.*;
import okhttp3.*;
public class main {
public static void main(String []args) throws IOException{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file","{{file}}",
RequestBody.create(MediaType.parse("application/octet-stream"),
new File("<file>")))
.addFormDataPart("language","{{language}}")
.addFormDataPart("password","")
.addFormDataPart("parameter","{ \"lang\": 8 , \"keys\":[], \"tableHandles\":[],\"extractType\":2}")
.build();
Request request = new Request.Builder()
.url("https://api-server.compdf.com/server/v1/process/idp/documentExtract")
.method("POST", body)
.addHeader("x-api-key", "{{apiKey}}")
.build();
Response response = client.newCall(request).execute();
}
}
Result:
File Type | File Description |
---|---|
.json | JSON file with intelligent document extraction completed |
Return Data Structure Explanation:
JSON Content Explanation
Return Parameter | Data Type | Description |
---|---|---|
code | String | Error code, "200" indicates success |
message | String | Error message |
data | Object | Return result |
+details | Object | Key information extraction result |
++Page-index | Object | Extraction result for the corresponding page number |
+++key | String | Key information field extraction result, key:value |
+++tables | Array | Key information table extraction result, tables:[ [table1], [table2] ] |
JSON Structure Example:
{
"code": "200",
"msg": "success",
"data": {
"details": {
"Page-1": {
"Order Date": "xxx",
"Order #": "xxx",
"Quote#": "xxx",
"Your estimated delivery date is": "xxx",
"tables": null
}
}
}
}