docling-project / docling-project/docling

Sending pdf pipeline options to docling_serve_api

Open
#2,601 2 comments 0 reactions 0 assignees View on GitHub
question triage/close-stale
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

Hi @dosu, can you tell me how I should be sending pdf pipeline options to the docling serve api? this is my current code, but it is not working:

```
# Check if file is a PDF
is_pdf = filename.lower().endswith(".pdf") or os.path.splitext(filename)[1].lower() == ".pdf"

if is_pdf:
# PDF pipeline options with OCR - using flat form-data parameters as per API schema
# Based on Docling Serve API schema: parameters are flat, not nested
form_data = {
"to_formats": "json",
"do_ocr": "true",
"force_ocr": "true", # Force OCR (similar to force_full_page_ocr)
"ocr_engine": "easyocr",
"ocr_lang": json.dumps(["en"]), # Array as JSON string
"do_table_structure": "true",
"table_mode": "accurate",
"table_cell_matching": "true",
"images_scale": "2.0",
"include_images": "true",
"do_code_enrichment": "false",
"do_formula_enrichment": "false",
"do_picture_classification": "false",
"do_picture_description": "false"
}
timeout = 600.0 # Increased timeout for OCR processing
print(f"1. Sending PDF '{filename}' to Docling with OCR options...")
else:
form_data = {"to_formats": "json"}
timeout = 300.0
print(f"1. Sending '{filename}' to Docling container...")

try:
async with httpx.AsyncClient(timeout=timeout) as client:
r = await client.post(
f"{docling_url}/v1/convert/file",
files=files,
data=form_data
)
r.raise_for_status()
print(" ✅ Received response from Docling.")

response_data = r.json()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.