How to extract text from a PDF (for analysis, search, or feeding to an AI)
Copy-pasting from a PDF gives you broken columns and mangled formatting. Here's how to pull clean text from any PDF โ and what to do when the PDF is really just images.
Why copy-paste from a PDF is so terrible
Everyone has tried it: highlight text in a PDF, paste into a doc, and get gibberish โ columns interleaved, ligatures broken (fi becomes a mystery character), hyphenated line-breaks preserved as-is, page numbers embedded in the middle of paragraphs.
This isn't your fault. PDFs weren't designed for text extraction. Internally a PDF describes text as "draw the character 'A' at coordinates (100, 500)" and doesn't necessarily store word boundaries, reading order, or paragraph structure. A text extractor has to reconstruct all of that.
Reddit threads on r/LangChain, r/LocalLLaMA, and r/dataisbeautiful surface this constantly because everyone trying to feed PDFs to an AI runs into it.
The one-line answer
Use PDF Text Extractor for text-based PDFs. It reconstructs reading order, joins hyphenated words, and strips repeated headers and footers. Drop the PDF, get clean text back.
For scanned PDFs (image-only, no embedded text), you need OCR โ a fundamentally different process. Extract to images first with PDF to JPG and run OCR separately.
How to tell if your PDF is text or scanned
Open the PDF, try to select a word. If your cursor turns into a text-selection I-beam and you can highlight the text, it's a text-based PDF and extraction will work. If your cursor stays as an arrow and you can only draw a selection rectangle around the whole thing, it's a scanned/image PDF and you need OCR.
You'd be surprised how many "PDFs" are really just stacks of images. Every scanned document, faxed contract, or "print-to-PDF"-from-a-scanner output falls into this category.
What "clean extraction" produces
Good text extraction gives you:
- Reading order that matches the visual page. Left column top-to-bottom, then right column top-to-bottom (not left-right interleaved by line).
- Paragraphs preserved. Double-newline between paragraphs, single newline inside.
- Joined hyphenated words. "compres-\nsion" becomes "compression".
- Ligatures unicode-normalized.
๏ฌbecomesfi. - Headers and footers removed (or clearly separated), so they don't interrupt body text on every page.
- Page markers optional. Sometimes you want
--- page N ---markers, sometimes you don't.
PDF Text Extractor exposes these as options.
Common use cases
- Feeding a PDF to an LLM (Claude, GPT, Gemini). Chatbots handle raw text much better than the PDF binary. Extract first, paste the text.
- Searching across a batch of PDFs. Extract each to .txt, grep across the folder.
- Quoting from a report in an email or doc. Extract, then copy the exact paragraph you need.
- Building a dataset. Research papers, filings, contracts โ extraction is step one for any downstream NLP.
- Translation. Machine translators work far better on clean text than on PDFs directly.
The scanned-PDF workflow
If your PDF is scanned (no selectable text), your extraction options are:
- OCR the PDF in place using Adobe Acrobat Pro or a dedicated OCR tool. Produces a searchable PDF where text sits invisibly on top of the images. PDF Text Extractor then works on the output.
- Extract as images, then OCR each image. PDF to JPG gives you one image per page, which you can feed to Tesseract, MacOS Live Text, iPhone camera live text, or a cloud OCR service.
OCR quality depends on scan quality. 300 DPI scans of typed text OCR near-perfectly. 150 DPI phone photos of handwritten notes OCR badly regardless of tool.
Extracting only specific pages
If you need text from pages 10-15 of a 500-page report, extract only those pages instead of all of them:
- Extract PDF Pages to isolate 10-15 into a new PDF.
- PDF Text Extractor on the small PDF.
Much faster and produces cleaner output than extracting everything and then finding the relevant section.
Common gotchas
- Tables come out as one column. Text extraction generally doesn't preserve table structure. For tables specifically, you need a table-extraction tool (Camelot, Tabula) โ beyond plain text extraction.
- Two-column layouts read left-right instead of top-bottom of one column. Better extractors detect columns; simpler ones don't. If yours produces interleaved text, try a different tool.
- Text in images inside the PDF doesn't extract. A chart with numeric labels won't produce those numbers as text. Only OCR can pull them out.
- Non-Latin scripts sometimes come out as
?????. Encoding issue โ the PDF didn't include a proper Unicode mapping for the font. Rarely fixable without re-typesetting.
The privacy piece
Contracts, medical reports, financial statements, tax returns, research papers under embargo โ the categories of PDF people extract text from most often are also the categories where uploading to a random online extractor is a bad idea.
PDF Text Extractor runs in your browser via PDF.js โ the same engine Firefox uses to render PDFs natively. The file never leaves your device, and the extracted text stays on your device too. For anything you'd then paste into ChatGPT or Claude, you at least have the choice of what to share, one paragraph at a time.