from ndi_sdk import NdiClient, ParseResultSource
schema = {
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"total": {"type": "number"},
},
"required": ["invoice_number", "total"],
}
with NdiClient() as client:
upload = client.documents.create_upload("invoice.pdf")
parsed = client.jobs.wait(client.documents.parse(upload, wait_seconds=30).job_id)
job = client.jobs.wait(
client.documents.extract(
ParseResultSource(job_id=parsed.job_id),
json_schema=schema,
wait_seconds=30,
).job_id
)
print(job.result.data)
for field in job.result.fields:
print(field.path, field.status, field.value)