Prompt
I’m building internal search and need OCR for scanned PDFs
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
For scanned PDFs in internal search, you typically want an OCR pipeline that:
- Detects whether a PDF already has text
- Runs OCR only on image-only pages
- Extracts layout-aware text
- Indexes both text and metadata for search
A solid approach:
Recommended pipeline
- Ingest PDF
- Check if text layer exists
- If yes: extract text directly
- If no / partial: render pages to images and OCR
- Preprocess images
- Deskew, denoise, increase contrast, binarize if needed
- Run OCR
- Good open-source options:
- Tesseract: easy, decent, but weaker on complex layouts
- PaddleOCR: better accuracy, strong for many document types
- EasyOCR: simple to use, moderate quality
- docTR: good for document OCR and structure
- Good open-source options:
- Post-process
- Fix hyphenation, line breaks, headers/footers
- Keep page numbers and bounding boxes if you need snippet highlighting
- Index
- Full text into your search engine
- Store per-page text + coordinates + document metadata
If you need production-grade quality
Consider a document AI service if allowed:
- AWS Textract
- Google Document AI
- Azure Document Intelligence
These are stronger for tables/forms and usually easier to operationalize, but cost more and may raise compliance concerns.
Key design choices
- Search relevance: keep OCR confidence scores and page boundaries
- Latency: OCR during ingestion, not at query time
- Incremental reprocessing: only OCR pages that changed
- Storage: save rendered page images temporarily, not permanently unless needed
Practical recommendation
If you want an open-source stack:
- PyMuPDF / pdfplumber for PDF text detection/extraction
- Poppler / pdf2image for rendering pages
- PaddleOCR for OCR
- Elasticsearch / OpenSearch for indexing
If you want, I can give you:
- a Python reference implementation,
- a cloud architecture for this pipeline, or
- a tool comparison for your use case.