Extracting PDFs and scans
PDFs are the main case and the one where routing matters most. A single file often mixes born-digital pages with scanned ones; Deskew decides page by page.
Send the file
Section titled “Send the file”curl https://api.deskew.dev/v1/extract \ -H "Authorization: Bearer $DESKEW_API_KEY" \ -F "file=@contract.pdf" \ -F "output=json" \ -F "bbox=true"r = requests.post( f"{API}/v1/extract", headers=HEADERS, files={"file": open("contract.pdf", "rb")}, data={"output": "json", "bbox": "true"},)form.append("file", new Blob([await readFile("contract.pdf")]), "contract.pdf");form.append("output", "json");form.append("bbox", "true");const res = await fetch(`${API}/v1/extract`, { method: "POST", headers, body: form });Digital pages
Section titled “Digital pages”Pages with a usable text layer are read with the text-layer engine: text with positions comes from the PDF itself, lines are grouped into paragraphs and headings by font size and spacing, and ruled tables are detected from the page’s lines. Bounding boxes are exact. These pages cost 1 credit and typically take well under a second.
A page is digital when enough of its area is covered by text boxes and the text is not garbage (no replacement characters, dictionary-like tokens). If a page passes that check but then yields no text, it is treated as scanned and OCR’d.
Scanned pages
Section titled “Scanned pages”Scanned pages are rendered, scored and prepared before OCR:
- Quality score from effective resolution, blur (Laplacian variance), contrast and skew angle. It is returned as
page_results[].quality_score(0–1, higher is better). - Deskew and rotate: the detected skew angle is corrected before OCR.
- OCR with
deskew-ocr. The output is validated for repetition loops, implausible length and empty output; a failure triggers one retry on an enhanced image (contrast equalisation, denoise, upscale), then escalation topremiumon paid plans. - Confidence is returned per page. A first pass below 0.72 triggers the retry (and escalation on paid plans). A page whose output still fails validation after that is marked
low_confidence: trueand carries apage N: low_confidence: …entry inwarnings[].
Bounding boxes on scanned pages come from the OCR model and are approximate. Blocks carry meta.bbox_source: "vlm-approx" so you can tell them from text-layer boxes.
Encrypted PDFs
Section titled “Encrypted PDFs”Send the password as a form field or in options:
curl https://api.deskew.dev/v1/extract \ -H "Authorization: Bearer $DESKEW_API_KEY" \ -F "file=@statement.pdf" \ -F "pdf_password=s3cret"{ "url": "https://example.com/statement.pdf", "options": { "pdf_password": "s3cret" } }The password is used only in worker memory and never logged; it is excluded from request logs and from the idempotency hash. A PDF that needs a password you did not supply fails with 422 password_protected.
Limits and failure modes
Section titled “Limits and failure modes”| Situation | Result |
|---|---|
| PDF has 0 pages | 422 empty_document |
| More than 2,000 pages | 422 too_many_pages |
| Cannot be opened | 422 corrupt_file |
| Wrong or missing password | 422 password_protected |
| Over 20 MB or more than 12 work units | Queued as a job (202) unless mode=sync, which returns 413 sync_limit_exceeded |
| A single page cannot be read | Counted in pages.failed; the job still completes |
What to check
Section titled “What to check”page_results[].enginetells you which path each page took. A document that is alltext-layeris exactly as reliable as its text layer.page_results[].low_confidenceandwarnings[]flag pages to review by hand.usage.enginessummarises the mix, for example{"text-layer": 10, "deskew-ocr": 2}.