# Extract text from PDFs, including scanned ones

> Markdown version of https://stella.sh/how/pdf-excel/extract-text-from-pdf for agents and LLMs.
> Get the text out of PDFs with Preview, Word or free OCR, or let Stella (stella.sh) do a whole folder, reading scans and two-column layouts in the right order.

For a PDF with real text, select all and copy, or open it in Word on Windows, which converts it to editable text. Scans are pictures, so they need OCR: on a Mac, Preview's Live Text lets you select words in the image; the free Tesseract does whole files. Stella (stella.sh) handles a whole folder: it copies the text where there is some, runs OCR on scans and saves a .txt next to each PDF.

- Checked: 14 November 2026
- Stella does it on: Windows, Mac, Linux

## Stella doing it

Recorded 14 November 2026 on Linux (Omarchy) with Claude Code with Opus, on a Claude plan.
Result: Nine text files in about 2½ minutes. Checked afterwards against an answer key written before the run: the text of all 9 PDFs within tight error limits (scans included), the two-column newsletter read column by column, one file per PDF named after it, and every PDF unchanged. The planning documents, the neighbours and the newsletter are fictitious, made for this run; the three scans were printed as slightly skewed, grainy images. The work is sped up 8×.

Video (48 s): https://stella.sh/media/proofs/pdf-excel/extract-text-from-pdf/proof.mp4

Transcript:

- 0:00 Stella on a Linux computer. A Planning documents folder in Downloads holds 9 PDFs, three of them scans.
- 0:01 The prompt: get the text out of every one and save a text file for each PDF.
- 0:14 Stella replies that it will run OCR on the scans and save a .txt next to each PDF.
- 0:20 Copying text and reading the scans, sped up 8×.
- 0:33 Done: nine text files, the scans read word for word, the newsletter's columns in reading order.

What Stella does:

1. Opens all 9 PDFs in the Planning documents folder and sorts them: six have real text, three are image-only scans
2. Copies the text out of the six typed PDFs exactly, reading the two-column newsletter left column first, then right, so sentences don't interleave
3. Runs OCR on the three scans (a site visit note, a 1964 deeds extract and a signed consent) and checks the result against each page image
4. Saves a .txt file with the same name next to each PDF; the PDFs themselves are unchanged
5. Reports which ones were scans and that nothing came out garbled

## The prompt to paste

```text
I've got a folder of planning PDFs in my Downloads called Planning documents. Some are scans. Get the text out of every one of them, so I can search and copy it, and save it as a text file for each PDF.
```

## Get the text out yourself

1. **PDFs with real text.** If you can select words in the PDF, the text is there: select all (Command-A or Ctrl-A), copy, and paste into a plain text editor. In a two-column layout check the order; some viewers copy across both columns line by line.
2. **Windows: open the PDF in Word.** Word opens PDFs and converts them to editable text (it says so when it opens). Then File, Save As, Plain Text. Scanned pages come through as text too, with mistakes on poor scans.
3. **Mac: Live Text in Preview.** On a scan, Preview lets you select text inside the page picture with Live Text. Select, copy and paste page by page. It's fine for a page or two, slow for a folder.
4. **Many files: Tesseract.** The free Tesseract OCR engine runs from the command line on Mac, Windows and Linux. It reads images, so turn each scanned page into a PNG first (or use a tool like OCRmyPDF that does it for you), then run `tesseract page.png out`.

## Where Stella stops

- Handwriting and very poor scans come out with mistakes; Stella checks OCR text against the page and says where it's unsure.
- Tables come out as lines of text, not columns. For a spreadsheet, see [extract a table from a PDF to Excel](https://stella.sh/how/pdf-excel/extract-table-from-pdf-to-excel).
- Text and page images go to the AI model you use in Stella as it checks the result; the OCR itself runs on your computer.
- Recorded on Linux, where the OCR engine and PDF tools were already installed. On a Mac or Windows PC Stella may install Tesseract first; scans in languages other than English need their language pack added.

## Questions

**How do I make a scanned PDF searchable instead of getting a text file?**
Add a hidden text layer to the PDF itself: see [make a scanned PDF searchable](https://stella.sh/how/pdf-excel/make-scanned-pdf-searchable).

**Why does copied text come out jumbled?**
Usually columns: the copy runs straight across both. Or the PDF stores letters in an odd order. Extracting by column, as Stella did with the newsletter, fixes the first.

**Can I get the text into Word with the layout?**
Yes: [convert a PDF to Word](https://stella.sh/how/documents/convert-pdf-to-word) keeps headings, tables and pictures, where a text file keeps only the words.

**Is Stella free for this?**
Yes. Free with the ChatGPT or Claude plan you already have. Sign in with your ChatGPT plan, or use your Claude plan through Claude Code, and this task costs nothing extra. New accounts also get a small free trial of Stella’s own models.

**Can I control what Stella changes on my computer?**
Yes. Stella works on Windows, Mac and Linux with your own files and shows each step in the chat, so you can watch it and stop it at any point. Tell it what it may not do, as the prompts on these pages do (“don't delete anything without asking”). In the Downloads recording it deleted nothing until it was told to go ahead. It also refuses commands that would wipe a whole disk, your home folder or system folders.

Sources: [Apple: Interact with text in a photo using Live Text in Preview on Mac](https://support.apple.com/guide/preview/prvw625a5b2c/mac), [Microsoft: Opening PDFs in Word](https://support.microsoft.com/office/opening-pdfs-in-word-1d1d2acc-afa0-46ef-891d-b76bcd83d9c8), [Tesseract OCR: installation](https://tesseract-ocr.github.io/tessdoc/Installation.html).

## Related problems

- [Make a scanned PDF searchable](https://stella.sh/how/pdf-excel/make-scanned-pdf-searchable.md)
- [Convert a PDF to a Word document you can actually edit](https://stella.sh/how/documents/convert-pdf-to-word.md)
- [Extract a table from a PDF to Excel](https://stella.sh/how/pdf-excel/extract-table-from-pdf-to-excel.md)
- [Find files containing text, whatever type of file they are](https://stella.sh/how/files-folders/find-files-containing-text.md)
- [Convert bank statement PDFs to Excel](https://stella.sh/how/pdf-excel/bank-statement-pdf-to-excel.md)
- [Reduce PDF file size when it's too large to email](https://stella.sh/how/pdf-excel/compress-pdf-too-large-to-email.md)

Get Stella: https://stella.sh/download. Free with the ChatGPT or Claude plan you already have.
