PDF To JSON
With the PDF to JSON tool, you can convert your PDF file into a JSON file. The following examples show how to upload a test PDF file and convert it into a JSON file using Java, Python languages.
java
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF TO Editable task
CPDFCreateTaskResult result = client.createTask(CPDFConversionEnum.PDF_TO_JSON);
// Get a task id
String taskId = result.getTaskId();
// Upload files
client.uploadFile(new File("test.pdf"), taskId);
// Execute Task
client.executeTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);
Python
# Create a client
client = CPDFClient(public_key, secret_key)
# Create a task
# Create an example of a Image to Json task
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_JSON)
# Get a task id
task_id = create_task_result.task_id
# File handling parameter settings
file_parameter = PDFToJSONParameter()
file_parameter.is_allow_ocr = file_parameter.ALLOW_OCR
file_parameter.type = file_parameter.TYPE_TEXT
# Upload files
client.upload_file('test.pdf', task_id, file_parameter)
# Execute task
client.execute_task(task_id)
# Query TaskInfo
task_info = client.get_task_info(task_id)
Needed Parameters
type
:Options to extract contents (0: text, 1: table) Default 0.
isAllowOcr
: Whether to allow to open OCR (1: yes, 0: no), Default 0.
isOnlyAiTable
: Whether to enable AI to recognize table (1: yes, 0: no) Default 0.
Result:
File Type | Description |
---|---|
.json | The JSON file after the transfer process is completed. |