Optical Character Recognition (OCR)

OCR

Optical Character Recognition (OCR) allows users to extract text and tables from scanned documents with ease.

Key Highlights

  • Extract text from images within PDFs and scanned documents within PDFs effortlessly.

  • Support for multiple languages and fonts.

Getting started

To OCR all pages of your document, add "ocr": "true" to the data dictionary in requests.post:

response = requests.post(
    api_url,
    files=files,
    data={
        "document_type": "hierarchical_v2",
        "ocr": "true"
    }
)

Automatic OCR detection

Extract automatically detects when individual pages in a document need OCR — for example, scanned pages or pages with no extractable text. This means OCR may run even when you pass "ocr": "false".

  • Passing "ocr": "true" forces every requested page through OCR.
  • Passing "ocr": "false" (or omitting it) does not guarantee OCR is skipped: if auto-detection determines a page is scanned or otherwise unreadable as native text, that page is still OCR'd so you get usable output.

Because of this, enhanced_table_extraction="true" is safe to use on scanned documents. When auto-detection triggers OCR, tables on those pages are still extracted correctly.

Specifying a language

OCR detects the document's language automatically. If you already know the language, you can pass the optional language parameter to guide OCR and improve accuracy. This parameter only affects requests that actually go through OCR (whether via "ocr": "true" or automatic detection); it has no effect on natively parsed documents.

When language is omitted, the language is detected automatically.

response = requests.post(
    api_url,
    files=files,
    data={
        "document_type": "hierarchical_v2",
        "ocr": "true",
        "language": "spanish"
    }
)

language must be one of the following supported values:

arabic, chinese_simplified, chinese_traditional, english, french, german, hebrew, italian, japanese, korean, portuguese, russian, spanish, thai.

Important Notes

  • Please expect throughput and latency increases when using OCR.

  • Accuracy may vary depending on image quality and text complexity.

  • Feedback is encouraged to improve accuracy and expand language support.

Feedback and Support

We value your feedback to enhance OCR's performance. If you encounter any issues or have suggestions, please reach out to extract@kensho.com.

Stay Updated

Keep an eye on our release notes for updates and improvements to OCR based on your feedback and usage.