How to convert scanned PDF to text with Nutrient's OCR API

Table of contents

    How to convert scanned PDF to text with Nutrient's OCR API
    TL;DR
    • Convert scanned PDFs to searchable text using Nutrient’s OCR API
    • Single API call with curl — no SDK installation required
    • Supports 80+ languages including Chinese, Japanese, Arabic, and European languages

    Use Nutrient API to convert a scanned PDF into a searchable document using optical character recognition (OCR).

    Why use OCR?

    Scanned documents are essentially images — you can’t select, search, or copy text from them. OCR extracts the text and embeds it into the PDF, making it:

    • Searchable — Find specific content instantly with Control-F
    • Selectable — Copy and paste text into other applications
    • Accessible — Screen readers can read the document aloud
    • Indexable — Search engines and document management systems can catalog the content

    Common use cases include:

    • Legal document archival — Digitize contracts, court filings, and case files for easy retrieval
    • Invoice processing — Extract text from scanned invoices for accounting systems
    • Healthcare records — Convert paper medical records to searchable digital format
    • Historical document preservation — Make old manuscripts and archives text-searchable

    Getting started

    You’ll need a sample PDF containing scanned images. Use this sample document if needed — the text isn’t selectable or searchable until OCR is applied.

    Step 1 — Create a free account

    Prerequisites: You’ll need curl installed and a Nutrient API key (free tier includes 50 credits).

    Create a Nutrient API account. The free plan includes 50 credits; different operations consume varying amounts.

    Copy your API key from the dashboard.

    Step 2 — Make a request

    Make a request to the /build endpoint with your API key and document:

    Terminal window
    curl -X POST https://api.nutrient.io/build \
    -H "Authorization: Bearer <YOUR-API-KEY>" \
    -o result.pdf \
    --fail \
    -F scanned=@document.pdf \
    -F instructions='{
    "parts": [
    {
    "file": "scanned"
    }
    ],
    "actions": [
    {
    "type": "ocr",
    "language": "english"
    }
    ]
    }'

    The result.pdf file now has searchable, selectable text.

    Supported languages

    Nutrient’s OCR API supports 80+ languages, including:

    CategoryLanguages
    EuropeanEnglish, French, German, Spanish, Italian, Portuguese, Dutch, Polish, Swedish, Norwegian, Danish, Finnish
    AsianChinese (Simplified/Traditional), Japanese, Korean, Vietnamese, Thai, Indonesian, Malay
    Middle EasternArabic, Hebrew, Persian, Turkish
    IndicHindi, Bengali, Tamil, Telugu, Gujarati, Punjabi
    OtherRussian, Ukrainian, Greek, Latin, and many more

    You can specify the language using either the full name (english) or ISO 639-2 code (eng). For documents with multiple languages, pass an array:

    Terminal window
    "language": ["english", "french"]

    See the complete language support documentation for the full list.

    Tips for better OCR accuracy

    Follow these best practices to maximize recognition quality:

    Image quality

    • Resolution — Aim for 200–300 DPI. Higher isn’t always better; resolutions above 300 DPI can degrade accuracy for larger fonts
    • Font size — Optimal range is 10–30 pt. Fonts larger than 30 px may be skipped or misinterpreted
    • Clarity — Use clean, high-contrast scans. Avoid noise, skewing, and heavy compression

    Let the API handle preprocessing

    Avoid manually preprocessing images before OCR. Nutrient’s OCR engine applies automatic preprocessing that typically yields better results than manual adjustments like deskewing or contrast enhancement.

    Choose the right language

    Specifying the correct language improves accuracy significantly. For multilingual documents, specify all relevant languages — the engine will detect which applies to each text region.

    Combine OCR with other operations

    The Nutrient API can chain multiple operations in a single request. After OCR, you can:

    • Merge documents — Combine multiple scanned files into one searchable PDF
    • Add watermarks — Stamp “CONFIDENTIAL” or company branding
    • Flatten annotations — Burn in form fields or comments
    • Compress — Reduce file size for archival

    Example combining OCR with watermarking:

    Terminal window
    curl -X POST https://api.nutrient.io/build \
    -H "Authorization: Bearer <YOUR-API-KEY>" \
    -o result.pdf \
    --fail \
    -F scanned=@document.pdf \
    -F instructions='{
    "parts": [
    {
    "file": "scanned"
    }
    ],
    "actions": [
    {
    "type": "ocr",
    "language": "english"
    },
    {
    "type": "watermark",
    "text": "CONFIDENTIAL"
    }
    ]
    }'

    Summary

    Nutrient’s OCR API transforms scanned documents into searchable, accessible PDFs with a single API call. Key capabilities:

    • 80+ languages — From English to Chinese to Arabic
    • No preprocessing required — The engine handles image optimization automatically
    • Chainable operations — Combine OCR with watermarks, merges, and compression
    • Simple integration — Works with curl, any HTTP client, or Nutrient SDKs

    Next steps

    FAQ

    What is OCR and how does it work?

    OCR (optical character recognition) analyzes images of text and converts them into machine-readable characters. The Nutrient OCR API scans your PDF, identifies text regions, recognizes characters, and embeds an invisible text layer that makes the document searchable and selectable.

    How many languages does Nutrient’s OCR API support?

    Nutrient’s OCR API supports over 80 languages, including English, Chinese (Simplified and Traditional), Japanese, Korean, Arabic, Hebrew, Hindi, and all major European languages. You can specify multiple languages for multilingual documents.

    Do I need to preprocess images before running OCR?

    No. Nutrient’s OCR engine includes automatic preprocessing that typically produces better results than manual adjustments. Avoid deskewing or contrast enhancement before sending documents to the API.

    What image resolution works best for OCR?

    Aim for 200–300 DPI. Resolutions above 300 DPI can actually degrade accuracy for larger fonts. Ensure scans are clean with good contrast and minimal noise.

    Can I combine OCR with other PDF operations?

    Yes. The Nutrient API supports chaining multiple operations in a single request. You can apply OCR and then add watermarks, merge documents, flatten annotations, or compress the file — all in one API call.

    Oghenerukevwe Henrietta Kofi

    Oghenerukevwe Henrietta Kofi

    Explore related topics

    Try for free Ready to get started?