DEV Community

Bence Kadi
Bence Kadi

Posted on AI-assisted

Scanned PDFs to clean text and tables, without retyping (OCR + Markdown)

I looked at a few hundred freelance data jobs this week. The single most common clean request (no personal data, no logins) was some version of: "I have a pile of PDFs, some of them scanned, and I need the text and tables in a usable format." Budgets were often in the hundreds of dollars, for work that is mostly mechanical.

This post shows how to turn PDFs (scanned or not), Word, PowerPoint and Excel files into clean Markdown with real tables, which you can paste into a spreadsheet, feed to an LLM, or search.

Disclosure: I built the tool used here, Document to Markdown on Apify.

Why plain "PDF to text" isn't enough

  • Scans have no text layer. Copy-paste gives nothing; you need OCR.
  • Tables fall apart. Most extractors give you numbers in a random order, one per line.
  • Two-column layouts get mixed, so sentences from the left column end up inside the right one.
  • Headers, footers and page numbers repeat on every page and pollute the result.

Step 1: Convert a document

Open Document to Markdown and paste one or more file URLs, or upload files:

{
  "urls": ["https://example.com/annual-report-scan.pdf"],
  "outputFormat": "markdown",
  "includeTables": true,
  "ocrMode": "auto",
  "ocrLanguages": ["eng"]
}
Enter fullscreen mode Exit fullscreen mode
  • ocrMode: auto runs OCR only on pages without a text layer, so normal PDFs stay fast and only real scans pay for OCR. Use always if a PDF has a broken text layer (garbled characters).
  • ocrLanguages: English, German, French, Spanish and Italian. Add only what you need; each extra language slows OCR down.
  • includeTables: tables come out as Markdown tables, including tables without vertical lines.

Step 2: Use the output

Each document becomes one row with a markdown field. Headings are detected from font sizes, two-column pages are read in the right order, and repeated headers/footers are removed. Invisible <!-- Page 3 --> markers let you cite the page a number came from.

To get a table into Excel or Google Sheets: copy the Markdown table into any "Markdown table to CSV" converter, or paste it straight into Google Sheets and use Data > Split text to columns with | as the separator.

Step 3 (optional): Chunks for an LLM

If the goal is "ask questions about these 300 contracts", set chunkSize (1,500-3,000 characters works for most embedding models). You get chunks[] split on headings, paragraphs and tables, each with the page numbers and heading path, ready for a vector database.

What to check before you deliver to a client

OCR is never 100%. For financial figures:

  1. Spot-check totals against the source (sum the column, compare with the printed total).
  2. Watch for the classics: 0/O, 1/l, 5/S, and decimal commas vs points.
  3. Keep the page markers so every number can be traced back.

That's still far faster than retyping, and the automated part is the same for 5 pages or 5,000.

Pricing

$2 per 1,000 documents (per started 20 pages), plus $2 per 1,000 OCR pages. Failed files (password-protected, no text and OCR off) are not charged.

Top comments (0)