PDF to TXT 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 to TXT:
{
  "enableAiLayout": 1,
  "enableOcr": 0,
  "ocrRecognitionLang": "AUTO",
  "pageRanges": "1,2,3-5",
  "txtTableFormat": 1
}Required parameters
enableAiLayout: Whether to enable AI layout analysis (0: not enabled; 1: enabled). Default 1.
enableOcr: whether to use OCR (0: not enabled; 1: enabled). Default is 0.
ocrLanguage: OCR recognition language. 1: CHINESE; 2: CHINESE_TRA; 3: ENGLISH; 4: KOREAN; 5: JAPANESE; 6: LATIN; 7: DEVANAGARI; 8: AUTO. Default is 8.
pageRanges: specify page number conversion, starting from 1. Default is empty.
txtTableFormat: whether to format the table when converting pdf to txt (0: not enabled; 1: enabled). Default is 1.
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/txt' \
--header 'x-api-key: apiKey' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"file"' \
--form 'password="" \
--form 'parameter="{  \"enableAiLayout\": 1,  \"enableOcr\": 0,  \"ocrRecognitionLang\": \"ENGLISH\"}"' \
--form 'language="1"'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","{  \"enableOcr\": 1}")
      .build();
    Request request = new Request.Builder()
      .url("https://api-server.compdf.com/server/v2/process/pdf/txt")
      .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 | 
|---|---|
| .txt | Converted TXT file | 
| File Type | Description | 
|---|---|
| .txt | The TXT file after the transfer process is completed | 
Asynchronous Request
If you need to use the file asynchronous processing flow, please read the Asynchronous Request Instructions.