Prompt
How do I OCR scanned PDFs through an API?
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
To OCR scanned PDFs through an API, you usually do this in one of two ways:
- Use a document OCR API directly
- Extract PDF pages as images, then send images to an OCR API
Typical flow
- Upload the scanned PDF to the OCR service
- Start an OCR job via API
- Poll for completion or receive a webhook callback
- Download results as text, JSON, searchable PDF, etc.
Common API options
Examples of services that support OCR for PDFs:
- Google Cloud Document AI / Vision
- AWS Textract
- Azure AI Document Intelligence
- OCR.Space
- PDF.co
- ABBYY Cloud OCR
- Tesseract-based custom API if you host your own
Example: general REST workflow
1) Send the PDF
curl -X POST https://api.example.com/ocr \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@scanned.pdf"
2) Get a job ID
{
"job_id": "abc123",
"status": "processing"
}
3) Poll status
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.example.com/ocr/abc123
4) Retrieve result
{
"status": "completed",
"text": "Hello world...",
"pages": [...]
}
If the API only accepts images
If the OCR API doesn’t accept PDFs, convert each page to an image first:
- Use
pdftoppm,imagemagick,poppler, orpdf2image - Send each page image to the OCR endpoint
- Merge results in order
Important considerations
- Scanned PDFs may need preprocessing: deskew, denoise, rotate, increase contrast
- Multi-page PDFs: check file size/page limits
- Output format: plain text vs structured JSON vs searchable PDF
- Async handling: large PDFs often need job-based APIs
- Security: encrypted PDFs may need unlocking first
Quick recommendation
If you want the simplest path:
- Use Azure Document Intelligence or AWS Textract for production OCR
- Use OCR.Space for lighter/simple integrations
- Use Tesseract if you want to self-host and avoid per-page API costs
If you want, I can show you:
- a Python example
- a Node.js example
- or a specific provider setup like AWS, Google, or Azure