Rachis

How do you extract reliable text from PDFs and scans?

22 November 2026, updated 28 November 2026

Before your application searches or cites a PDF, it extracts text from the file. Text that extraction drops, scrambles or invents can change search results, answers and the pages citations point to. This piece gives you a first setup to try and a way to check the extracted text against your own files.

Start with the text stored in the PDF

A PDF's text layer is the characters the file itself stores, which a program can copy out without reading the page as an image. Pages that hold only images, such as scans, need optical character recognition (OCR), which reads text from page images.

Unstructured's open-source PDF extraction defaults to auto: it chooses fast to extract an available text layer and ocr_only to run OCR otherwise, unless table extraction is switched on, which selects hi_res.

A text layer can be broken: a PDF looks correct on screen but copies out as garbage because a font does not map drawn shapes to real characters. Docling's replace_broken_text_layer option, off by default, detects pages with a broken text layer and reads them with OCR instead.

It cannot detect a page whose text uses the right alphabet but the wrong letters, or the right letters in the wrong order, such as "Cartifecita" for "Certificate". Such pages keep their PDF text.

Preserve reading order and table structure

Layout analysis identifies elements such as headings, columns and tables and determines the order in which text is read.

Take a traveller who uploads their policy's schedule of cover and asks for the cancellation limit. If extraction attaches the baggage amount to the cancellation row, an answer built from the extracted text can give that amount as the limit.

A Docling user extracting a non-scanned PDF of US election data reported that the rows for UT and VT were merged. In a later reply, after a bot suggested settings, they reported an empty row between NV and NJ where NH should have been, and wrong values in the NV row.

The tables and layout collection gathers related builder reports.

A 2026 study tested 15 models converting French PDF page images into Markdown, a text format that marks headings, lists and other structure. The pages were chosen where two conversion models disagreed most, which the authors say biases the benchmark toward pages where current systems are unstable.

For multi-column pages and long tables, small deviations in the order the page's regions were read, or in how a table was written out as text, could make the benchmark's reading-order and table checks fail. This could happen even when text recognition was strong. The study measured conversion only, without testing search or answers.

Account for every page

Processing an approximately 700-page, math-heavy PDF, one Docling user reported memory errors after which processing continued but layout analysis was silently skipped for the failed pages. The author later reported that the latest version solved the memory problem.

An empty page of text can be a scan that was never read. PyMuPDF documents that pages without selectable text return empty strings when OCR is disabled. The same behaviour applies when neither of its default OCR engines, Tesseract or RapidOCR, is installed.

Record an outcome for every source page, including blank pages and extraction failures. Reports of incomplete processing appear in the large documents and lost pages collection.

Compare OCR wording with the page image

A Docling user who uploaded an English scan in OpenWebUI, with Docling as its parsing engine, reported that some paragraphs became meaningless strings of letters.

Scans also need checking for invented text. One person reported on Hacker News that Mistral OCR 4.0 invented whole sentences during their small-scale OCR work. A proofreading pass with Claude, given the same input images and the Mistral output, caught them. The author later wrote that the errors were small in size: "Single sentences, formatting errors, paragraphs with newlines."

The scans and OCR quality collection gathers more builder reports.

Another 2026 study tested 10 OCR models on 570 documents, then measured evidence coverage and answer accuracy in a fixed search-and-answer setup.

The authors found that high OCR accuracy does not necessarily translate into strong search-and-answer results: structural and semantic errors can cause substantial search failures even when character and word error rates remain low.

Structural and semantic errors are extraction errors that lose the document's organization or the meaning carried by its layout and formatting. The findings concern systems that extract text before search.

Check right-to-left reading order

A RAGFlow user parsing Arabic PDFs with its Deepdoc parser reported left-to-right extraction that produced scrambled, unreadable passages. The issue was closed after a contributor suggested raising a feature request, and no fix is reported in the thread.

For Arabic or other right-to-left documents, compare whole lines with the original, including lines mixing text and numbers. Check separately that table columns follow the same order as on the page. Related reports appear in the Arabic and right-to-left text collection.

Keep the original page locations

Keep each extracted block linked to its original page and position so citations can open the source passage.

For example, Docling's location records include a page number and a bounding box, the rectangle enclosing the extracted element. Preserve those records alongside the text when you prepare it for search.

A first setup and a check

Start by using the text layer where it is present and reads correctly, and OCR for pages that hold only images or whose text layer is broken.

In Docling, set do_ocr=True and turn on replace_broken_text_layer in the OCR engine's options; it is off by default. Pick an OCR engine and language that can read your documents.

In Unstructured, set the strategy to hi_res, the only strategy that currently extracts PDF tables. It currently has difficulty ordering elements in multi-column documents.

Pick text-layer PDFs, scans, multi-column, table-heavy and long documents, including right-to-left files if you have them. Compare input and output page counts, accounting for blank pages. Compare extracted pages with the originals for headings, reading order, and table rows and columns.

Search extracted text for phrases visible on the page. For scans, compare several lines word for word. Confirm every extracted block retains its page number.

Keep test questions that depend on tables or scans, together with their checked answers and source passages. After changing extraction settings, compare extracted pages and rerun those questions.

Join the waitlist: one email when there is something to try.

Read the pain map: Ingestion.