Image To TXT
With the Image to Json tool, you can convert your Image file into a TXT file. The following examples show how to upload a test Image file and convert it into a TXT file using Java languages.
java
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a Image to TXT task
CPDFCreateTaskResult result = client.createTask(CPDFConversionEnum.IMAGE_TO_TXT);
// Get a task id
String taskId = result.getTaskId();
// File handling parameter settings
CIMGToTxtParameter fileParameter = new CIMGToTxtParameter();
fileParameter.setIsAllowOcr(CIMGToTxtParameter.IS_ALLOW_OCR);
// Upload files
client.uploadFile(new File("test.jpg"), taskId, fileParameter);
// Execute task
client.executeTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);
Needed Parameters
isAllowOcr
: Whether to allow to open OCR (1: yes, 0: no), Default 0.
isContainOcrBg
: Whether to keep the background image after OCR is enabled (1: yes, 0: no) Default 0.
Result:
File Type | Description |
---|---|
.txt | The TXT file after the transfer process is completed. |