How to Extract Text From a PDF
Copy text out of a PDF cleanly, without broken lines or scrambled columns. Why PDFs are awkward to copy from, what to do about tables, and why scans come out empty.
Updated · 4 min read
You select a paragraph in a PDF, paste it, and get a mess: line breaks in the middle of sentences, words broken apart, page numbers in the text, columns mixed up. Nothing is wrong with your computer. It comes from how PDFs work.
Why copying from a PDF goes wrong
A Word document stores text as paragraphs. A PDF stores instructions for placing characters on a page: this word at this position, that word at that one. The format is designed to look the same everywhere, not to preserve the structure of the text.
So a PDF doesn't really know what a paragraph, a column or a table is. Software has to guess that structure from the positions of the words. That leads to the usual problems:
- Hard line breaks at the end of every printed line
- Hyphenated words split across two lines
- Columns read straight across the page
- Headers and footers repeated in the middle of the text
- Tables that collapse into a single column of values
The quick way
- Open PDF to Text and drop in your file.
- Choose all pages or a page range.
- Pick a layout mode.
- Copy the text or download it as a TXT or Markdown file.
The file is read in your browser and isn't uploaded, so it's fine for contracts and other private documents.
Choosing the right mode
The choice of mode makes the biggest difference.
Reading order produces flowing paragraphs. Use it for reports, articles, books and anything you'll edit or quote. It can also rejoin words hyphenated at line ends and remove repeating headers, footers and page numbers.
Keep layout places text on a fixed-width grid, so that columns and indentation stay where they were on the page. Use it for tables, invoices, forms and code.
If one mode looks wrong, try the other one. Multi-column papers often need reading order, and a statement full of numbers usually needs keep layout.
Why the result is empty
If you get nothing, or only a few stray characters, your PDF is almost certainly a scan or a photo. Each page is then an image with no text in it at all, so there's nothing to extract.
A quick test: open the PDF and try to select a single word with the mouse. If you can't, or the whole page gets selected like a picture, there's no text layer.
To get text out of a scan, you need OCR (optical character recognition), which reads the letters from the image. Most scanner apps, Google Drive and Microsoft OneNote offer it, and so do desktop PDF editors. PDF to Text doesn't do OCR. Keep in mind that OCR makes mistakes, especially with small print, handwriting, and characters that look alike, such as 0 and O. Always check numbers and names by hand.
When the text looks like nonsense
Sometimes a PDF has text, but it comes out as garbled symbols. This happens when a PDF uses a font with custom encoding and no map back to real characters. The page looks right because the shapes are drawn correctly, but the underlying codes mean nothing. Extraction tools can't fix this. The only way forward is to treat the page as an image and use OCR.
Working with tables
Tables are the hardest case, as a PDF has no concept of cells. Keep layout gets you the closest, since it preserves the columns as spacing. To turn that into a spreadsheet, try one of these approaches:
- Paste the result into a spreadsheet and use the "text to columns" feature.
- Copy one table at a time rather than the whole document.
- Check the totals afterwards. A value that slips into the wrong column is easy to miss.
Handling long documents
For a 300-page report, don't extract everything if you only need chapter four. Use a page range, or cut the section out first with Split PDF. That gives you a cleaner result and much less to check.
You can also download one text file per page. This helps if you need to keep page references, for example when you're citing a source or preparing text for search.
Finding what changed
If you're extracting text to see what changed between two versions of a document, there's a shorter route. Compare PDF shows the differences between two PDFs directly, as a visual overlay or as a text diff. If you already have plain text from both versions, a text diff does the same job.
Clean up afterwards
Even a good extraction usually needs a final pass:
- Search for double spaces and stray line breaks with a find and replace tool.
- Check headings, because they often lose their formatting.
- Check footnotes. They can land in the middle of a paragraph.
- Check ligatures. Some fonts join letters such as "fi", and these can come out as a single odd character.
And remember the copyright side. Being able to extract text from a PDF doesn't mean you can republish it. For a quotation, say where it came from.