Clioos › Guides › PDF to Text

How to Convert PDF to Text

By Clioos 团队

The free offline way is pdftotext: one command turns a text-based PDF into a plain-text file. Tested 2 November 2026 with pdftotext 24.02.0 (Poppler) — a 2-page text PDF extracted both pages cleanly, while an image-only PDF of 76,642 bytes extracted just 1 byte: nothing. That boundary is the whole guide: pdftotext reads the PDF's text layer, and a scanned page has no text layer to read.

At a glance

Steps

  1. Install Poppler if needed (most Linux systems already have it; macOS: brew install poppler). Check with pdftotext -v (24.02.0 in the test).
  2. Run: pdftotext sample.pdf sample.txt. For tables, run: pdftotext -layout sample.pdf sample.txt.
  3. Verify: the test text PDF extracted “Quarterly report: revenue rose 12 percent in Q3.” and “Page two: outlook for Q4 is cautiously positive.” — both pages, verbatim.
  4. Diagnose an empty result: run pdftotext scanned.pdf - | wc -c. The test image-only PDF returned 1 byte — proof the page is a picture, not text. OCR it first; re-running pdftotext will not help.

Worked example (tested 2 November 2026)

Method: pdftotext 24.02.0 (Poppler), run locally on two test PDFs. No upload, no account.

InputResult
sample-text.pdf, 2 pages with a real text layerBoth lines extracted verbatim: “Quarterly report: revenue rose 12 percent in Q3.” and “Page two: outlook for Q4 is cautiously positive.”
scanned-style.pdf, image-only, 76,642 bytesOutput was 1 byte — empty. No text layer, nothing to extract.

The difference is not quality; it is kind. One PDF contains text, the other contains a picture of text, and pdftotext can only return what is there.

What it can't do

Frequently asked questions

Is pdftotext free?

Yes — part of Poppler, free and open source, runs offline on your own computer.

Why did my PDF extract nothing?

Almost certainly it is image-only (a scan or photo). Check with pdftotext to stdout and count the bytes: near-zero means no text layer. OCR the PDF first.

Can pdftotext convert a PDF table to Excel?

No — it outputs text. For a spreadsheet, use a PDF-to-Excel converter; -layout only keeps the visual positions in text form.

Does it work on encrypted PDFs?

Only if you supply the password (pdftotext -upw). Without it, an encrypted PDF extracts nothing.


Related guides: How to convert a scanned PDF to Excel · How to convert PDF to Excel · How to convert PDF to Word · All guides · Tool: PDF Probe