PDF to Text: Extract Text from Any PDF for Free

November 11, 2026 · 12 min read

PDF to Text: How to Extract Text from a PDF for Free

To convert a PDF to text, first check whether the file has a real text layer. If it does, copy and paste, Google Docs, the free pdftotext command or a few lines of Python will pull the text out in seconds. If it's a scan, you need OCR first. This guide shows each method with tested commands and output.

Does Your PDF Have a Text Layer?

Open the file and try to select a single word. If the word highlights on its own, the PDF stores real characters and every method below works. If you can only draw a box over the whole page, you're looking at a picture of text, usually a scan or a phone photo saved as PDF.

On the command line, pdffonts from Poppler gives a firmer answer. It lists every font the file uses, and a page that's only an image uses no fonts at all.

pdffonts report.pdf

A text-based file prints one row per font:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
Helvetica                            Type 1            WinAnsi          no  no  no       2  0
Helvetica-Bold                       Type 1            WinAnsi          no  no  no       3  0

A pure scan prints just the two header lines and nothing under them. That one check tells you which path to take:

Your PDFFastest free methodHandles scans
A page or two, text layerCopy and pasteNo
Small files, no install wantedGoogle DocsYes
Many files or long reportspdftotextNo
Text inside a script or apppypdf or pdfplumberNo
Scanned or a phone photoOCRmyPDFYes

Google Docs is the only method in the table that uploads your file. The other four run offline on your own machine.

Copy and Paste Text from a PDF Viewer

For a short document, the quickest way to extract text from PDF files is the viewer you already have. Chrome, Edge, Firefox, macOS Preview and Adobe Acrobat Reader all let you select text in a PDF that has a text layer.

  1. Open the PDF and click inside the page.
  2. Press Ctrl+A (Cmd+A on a Mac) to select all, then Ctrl+C to copy.
  3. Paste into a plain text editor such as Notepad or TextEdit in plain text mode.

Pasting into a plain text editor matters. Word processors keep fonts and odd spacing, which you then have to strip back out.

Expect three problems. Each line usually ends in a hard line break, and words split across lines often keep their hyphen (custom- and ers). Two-column pages can also paste in the wrong order. The cleanup section near the end fixes all three. Some PDFs also set a permission that blocks copying, and many viewers respect it.

Can Google Docs Convert a PDF to Text?

Yes, and it's the easiest free option for a scan, because Google Drive runs OCR during the conversion. Upload the PDF to Drive, right-click it, then choose Open with and Google Docs. Drive creates a new document with the recognized text.

From there, choose File, then Download, then Plain text (.txt) to save a clean text file.

Google's help page lists the limits. The file should be 2 MB or smaller, text should be at least 10 pixels high, and pages must be right-side up. Google also warns that lists, tables, columns, footnotes and endnotes probably won't be detected, so check those parts by eye.

Desktop Microsoft Word can also open a PDF as an editable copy. The FAQ at the end covers that route and its limits.

Convert PDF to Text on the Command Line with pdftotext

pdftotext ships with Poppler, a free PDF library. It runs locally, so your file never leaves your machine, and it handles hundreds of files in one go. We prefer it for anything longer than a few pages.

Install it with your package manager:

# macOS (Homebrew)
brew install poppler

# Debian or Ubuntu
sudo apt install poppler-utils

# Windows (conda-forge)
conda install -c conda-forge poppler

The basic run writes report.txt next to report.pdf:

pdftotext report.pdf

We tested every example here with Poppler 25.10 on a one-page report that has a title, a two-column block and a footer. The default mode undoes the columns and rejoins the word that was hyphenated across a line break:

Quarterly Report
Revenue grew 12% in Q3,
driven by new customers in Europe.

Page 1 of 1

Costs stayed flat at
4.1 million while the
team grew to 40.

The columns come out one after the other, though the footer lands between them. Add -layout and the text keeps its position on the page instead, which suits tables and forms:

pdftotext -layout report.pdf -
Quarterly Report
Revenue grew 12% in Q3,   Costs stayed flat at
driven by new custom-     4.1 million while the
ers in Europe.            team grew to 40.

Page 1 of 1

The trailing - sends the text to the terminal instead of a file. The other flags you'll reach for most, all documented on the pdftotext man page:

# Only pages 2 to 5, piped into grep
pdftotext -f 2 -l 5 report.pdf - | grep -i revenue

# No form feed characters between pages
pdftotext -nopgbrk report.pdf

# A password-protected file
pdftotext -upw 'your-password' locked.pdf

# Every PDF in the folder, one .txt per file
for f in *.pdf; do pdftotext -layout "$f"; done

Poppler writes UTF-8 by default, and -enc picks another encoding such as Latin1 if an older program needs it. If accented letters look wrong, check that your text editor opens the file as UTF-8. The same Poppler package includes pdftohtml, which our guide to converting PDF to HTML covers flag by flag.

How Do You Extract Text from a PDF in Python?

Use pypdf for plain text and pdfplumber when you need control over which part of the page you read. Both install with pip. We tested with pypdf 7.0.1 and pdfplumber 0.11.10.

pip install pypdf pdfplumber

With pypdf, open the file, loop over its pages and call extract_text():

from pypdf import PdfReader

reader = PdfReader("report.pdf")
text = "\n".join(page.extract_text() for page in reader.pages)
print(text)

On our two-column sample, the default mode follows the order in which the PDF draws the text, so the columns interleave line by line:

Quarterly Report
Revenue grew 12% in Q3,
Costs stayed flat at
driven by new custom-
4.1 million while the
ers in Europe.
team grew to 40.
Page 1 of 1

Depending on how the file was built, pypdf may instead print a line from each column on the same row. Either way the columns mix. Pass extraction_mode="layout" to extract_text() and pypdf keeps the columns side by side, much like pdftotext -layout. The pypdf text extraction docs explain why no setting is perfect: each character sits at a fixed spot on the page, and the file records nothing about paragraphs, headers or tables.

pdfplumber lets you crop a region before extracting it. This reads only the left half of the page, which fixes the column mix-up:

import pdfplumber

with pdfplumber.open("report.pdf") as pdf:
    page = pdf.pages[0]
    left = page.crop((0, 0, page.width / 2, page.height))
    print(left.extract_text())
Quarterly Report
Revenue grew 12% in Q3,
driven by new custom-
ers in Europe.
Page 1 of 1

For grids with ruled lines, page.extract_tables() returns each table as a list of rows. It's the closest you'll get to keeping a table's structure in plain text. For Markdown output from a Python script, see our guide to Microsoft's MarkItDown library.

How Do You Extract Text from a Scanned PDF?

A scanned PDF holds images, so pdftotext, pypdf and copy and paste all return nothing. To extract text from scanned PDF pages, you need OCR, which recognizes the letters in each page image. Google Docs (above) is the no-install option. Adobe Acrobat's paid desktop app also has OCR. If you still have the original photo or screenshot, an image to text converter reads it directly, with no PDF step.

For a local, free route, OCRmyPDF adds a text layer and can write the recognized text to a separate file at the same time. It's available through Homebrew, apt and pip. The --sidecar option comes from the OCRmyPDF cookbook:

ocrmypdf --sidecar scan.txt scan.pdf scan-ocr.pdf

You get a searchable scan-ocr.pdf and the plain text in scan.txt. Files that mix typed and scanned pages need more care. By default, OCRmyPDF exits without changing the file if any page already has text. Add --skip-text (also written --mode skip from version 17) and it OCRs only the image pages. Text from the typed pages doesn't appear in the sidecar, so run pdftotext scan-ocr.pdf afterwards to capture everything.

OCR accuracy depends on scan quality, and it's never perfect, so proofread names and numbers. For a structured Markdown result from a scan, our PDF to Markdown walkthrough covers the full pipeline.

Free Online PDF to Text Converters and the Upload Trade-off

An online converter is handy when you can't install anything. The trade-off is that your file goes to someone else's server. Before you upload a contract or a payslip, check how long the service keeps files and whether it runs OCR or only reads the text layer.

We don't offer a direct PDF to .txt download, but there's a two-step route on this site. Our PDF to Markdown converter runs on our server and reads only the PDF's text layer. It does no OCR, so scans give little or nothing back. Each conversion uses one of the 3 free server-side operations you get each day, no account needed.

Then paste the result into the Markdown to text tool, which runs in your browser and strips the Markdown markers. Our guide to turning Markdown into plain text explains what that step removes.

Why Extracted PDF Text Comes Out Garbled

Every method above can return text that's technically correct but awkward to use. These are the problems you'll hit most, with a fix for each.

  • Columns read across the page. Run plain pdftotext without -layout, or crop each column with pdfplumber.
  • Ligatures. Characters like fi and ff are single code points, so a search for "final" misses them. Normalize them with Python's unicodedata.normalize("NFKC", text).
  • Gibberish characters. Some fonts carry no usable Unicode mapping, so the extractor can't tell which letter a glyph is. OCR the page instead. The uni column in pdffonts won't settle it, because standard fonts like the Helvetica rows above show no and still extract cleanly.
  • Repeated headers and footers. Crop them away with pdfplumber, or with the -x, -y, -W and -H crop flags in pdftotext.
  • Hard line breaks and split words. Rejoin them with a short script. Our guide to removing line breaks from text shows how in Notepad++, VS Code and the terminal.

This snippet handles ligatures, hyphenated line ends and single line breaks, while keeping blank lines between paragraphs:

import re
import unicodedata

text = unicodedata.normalize("NFKC", text)
text = re.sub(r"(\w)-\n(\w)", r"\1\2", text)
text = re.sub(r"(?<!\n)\n(?!\n)", " ", text)

It turns driven by new custom- and ers in Europe. into one clean line. The limitation: it also joins real compound words that happen to break at a hyphen, such as well-known, so skim the result. None of these tools reliably rebuilds complex tables either.

Quick Answers on PDF Text Extraction

Getting a PDF to text comes down to one question: does the file have a text layer? If it does, use copy and paste for a page, pdftotext for volume and pypdf for scripts. If it doesn't, run OCR first. When you'd rather not install anything, run the file through our PDF to Markdown converter, then strip the markers or tidy the result in the editor.