Back to All Guides
OCR11 min readUpdated 2026-10-21

How to Convert Scanned PDF to Searchable Text with Optical Character Recognition (OCR)

The Science of Neural Text Extraction, Binarization, and Searchable Sandwich PDF Architecture

I
IMON Khan
Lead Systems Architect at AmarPDF
Executive Summary & Key Takeaways
  • A raw scanned PDF is merely a photographic bitmap container; computer systems cannot search, copy, highlight, or index its words without OCR.
  • Searchable 'Sandwich' PDFs maintain the original scanned image on top while mapping an invisible, precisely calibrated text layer underneath.
  • Pre-processing steps—Otsu's binarization, deskewing, and contrast normalization—account for up to 70% of OCR character recognition accuracy.
  • Modern client-side OCR harnesses compiled Tesseract 5 WebAssembly runtimes with Long Short-Term Memory (LSTM) neural networks.

The Bitmap Reality: Why Scanners Do Not Produce True Text

When a flatbed scanner or office multifunction printer scans a paper document and outputs a PDF, it does not understand letters, numbers, or sentences. It simply captures a photographic grid of millions of microscopic color dots (pixels) and encapsulates that bitmap image inside a PDF wrapper object (`/XObject /Subtype /Image`). To your computer's operating system, a scanned 100-page historical book or tax invoice is identical to a photograph of a sunset. You cannot: - Use `Ctrl+F` or `Cmd+F` to search for specific vendor names or invoice numbers. - Highlight, select, or copy text into an email or Word document. - Ingest the document into enterprise document management systems (DMS) or ERPs for automated workflow automation. - Allow visually impaired users to read the document via screen-reading accessibility software. Transforming this dead image into live, interactive digital data requires **Optical Character Recognition (OCR)**.

Under the Hood: The 3-Stage OCR Processing Pipeline

Modern neural OCR engines (such as Tesseract v5 and modern deep learning models) execute three rigorous algorithmic steps: 1. **Pre-Processing (Image Conditioning):** - **Deskewing:** Corrects rotational tilt caused by misaligned paper feeder trays by calculating Hough transforms across text baselines. - **Binarization (Otsu's Global Thresholding / Bradley Adaptive Thresholding):** Converts complex 24-bit RGB scans into high-contrast 1-bit monochrome (pure black text on pure white background), stripping away paper discoloration, coffee stains, and scanner shadows. - **Denoising:** Cleans up specks and scanner glass dust particles via morphological opening and closing filters. 2. **Text Segmentation & Neural Feature Extraction:** - The engine groups adjacent black pixels into Connected Components (CCs), identifies text baselines, and segments the page into columns, paragraphs, lines, and word bounding boxes. - An LSTM (Long Short-Term Memory) recurrent neural network evaluates character sequences in context, predicting not just individual character glyphs but the highest probability word combinations based on natural language dictionaries. 3. **Synthesis into Searchable 'Sandwich' PDF:** - Rather than replacing your original document with crude text, the OCR engine constructs a **Searchable Sandwich PDF**. The original visual scan remains visible on top. Directly behind every word, the engine injects an invisible vector font layer positioned at the exact X-Y coordinates of the scanned letters. - When you drag your mouse across the page, your cursor selects the invisible text layer, while your eyes admire the original authentic scan.
OCR Accuracy Optimization Benchmarks by Pre-Processing Technique
Input ConditionRaw Scan AccuracyWith Pre-Processing (AmarPDF)Primary Improvement Factor
300 DPI Clean Office Scan94.2%99.4%Adaptive thresholding & baseline leveling
150 DPI Fax / Receipt72.1%91.8%Morphological noise reduction & contrast stretching
Smartphone Photograph (Skewed)58.3%88.6%Perspective rectification & deskewing filters
Multi-Column Journal / Magazine64.0%96.5%Advanced recursive layout segmentation
Non-Latin Script (Bengali, Arabic, Devanagari)61.5%93.2%Specialized language LSTM sub-networks

Proven Best Practices for 99%+ OCR Accuracy

To ensure maximum character recognition precision when converting documents: - **Scan at 300 DPI:** Scanning at 150 DPI cuts the pixel data representing font serifs in half, confusing similar characters such as 'e' vs 'c', '1' vs 'l', or '8' vs 'B'. 300 DPI provides the ideal balance between neural recognition accuracy and file size. - **Avoid Heavy JPEG Compression Before OCR:** Lossy JPEG compression introduces 8x8 pixel block artifacts around text strokes. Always save intermediate raw scans as lossless PNG or uncompressed TIFF before running OCR. - **Select Specific Language Dictionaries:** If your document contains multilingual content (e.g., English mixed with Spanish, German, or Bengali), specify the target language models in AmarPDF. This enables the neural engine to load specialized vocabulary lexicons and accent-mark classification matrices.
In-Depth FAQ

Frequently Asked Technical Questions

What is a 'Searchable Sandwich PDF'?

A sandwich PDF is a dual-layer document. The top layer displays the exact visual scan of your paper document, while an invisible, perfectly aligned text layer sits underneath. This lets you select, copy, and search words without altering the authentic visual appearance of historical documents.

Can AmarPDF perform OCR directly in my web browser?

Yes! AmarPDF leverages compiled WebAssembly ports of Tesseract 5 with SIMD instruction sets, allowing fast client-side OCR recognition directly inside Chrome, Edge, Safari, and Firefox without sending confidential files to remote servers.

Can OCR recognize handwritten cursive text?

Modern OCR engines excel at machine-printed typography and clear, block-letter handwriting. However, irregular cursive script and artistic signatures require specialized handwriting recognition (ICR) models and may require manual transcription verification.

I
Written by IMON Khan
Lead Systems Architect at AmarPDF

Systems engineer specializing in high-performance document compilers, stream compression algorithms, and client-side WebAssembly execution.