Extract Text from PDF

Extract text to TXT or Markdown in correct column order

1Choose file2Settings3Process4Save

Choose a PDF and its contents will be analyzed and shown here.

Files are processed only in this browser. Nothing is uploaded to a server.

Extract text to TXT or Markdown with multi-column reading order fixed

Continue in another tool
Task settings
Output settings
1 / 1

Numbers show the reading order used for extraction. Grey dashed boxes are headers and footers that get removed.

Text preview

Remove the password from an encrypted PDF first. Processing focuses on page content, so bookmarks, attachments, forms and signatures may not be preserved. Keep the original and check the result.

About Extract Text from PDF

Text inside a PDF is not stored as sentences. It is a list of instructions — draw this glyph of this font at this position — and very often the file has no notion of lines, paragraphs or reading order at all. This tool reads the text runs with pdf.js, together with their positions and sizes, and rebuilds lines, columns, paragraphs and headings from the geometry alone.

So two things decide the quality of what you get. First, whether the PDF records what each glyph means in Unicode. Second, whether the layout can be inferred from coordinates. Pages with no text layer at all, such as scans, come back empty, and the tool points you to OCR.

Why extracted text comes out as gibberish

Embedded fonts are usually subsets containing only the glyphs used, and the page content refers to glyph numbers inside that font rather than to characters. The table that maps those numbers back to Unicode is the ToUnicode CMap. When it is missing or wrong, a page can look perfect on screen while copy-paste yields random symbols, accented junk or blank boxes — the shapes can be drawn without knowing what they mean. Ligatures are a milder case: “fi” drawn as one glyph may come out as a single ligature character, or not at all.

Type 3 fonts define each glyph with ordinary PDF drawing operators, and they often carry no Unicode information whatsoever. They turn up in output from older TeX setups, some CAD and reporting tools, and odd converters. No extractor can recover text that the file never recorded; rendering the page and running OCR is the practical route. A quick test: copy a sentence in your PDF viewer and paste it into a plain-text editor. If it breaks there, extraction will break too.

Why the order gets scrambled, and how this tool orders text

A PDF may draw its text in any order. Some two-column papers draw the first line of the left column, then the first line of the right, and so on; others draw headers and footnotes last. Following the file's order interleaves the columns line by line, which is the classic symptom of naive extraction.

This tool ignores the file's order and recomputes it with a recursive XY-cut. Glyphs are stacked into horizontal slabs; when several slabs share an empty vertical gutter at the same position, that region is treated as multi-column, split at the gutter, and each column is processed the same way. Output runs region by region from the top, and left to right across columns within a region. A figure caption that spans both columns, or a table that crosses the gutter, breaks the gutter and can put parts out of order.

Rotated and vertical text is taken out of the column analysis and read separately. Sideways table headers and 90° drawing labels are grouped by angle and read as lines in their own direction; vertical Japanese is read column by column from the right, top to bottom. Both are added as separate paragraphs after the page's horizontal text, not put back into their original spot (such as a table cell).

How spaces and line breaks are restored

Many PDFs never store a space character; they simply move the pen. The tool inserts a space when the gap between two glyphs exceeds 0.12 times the font size. Between Korean, Chinese or Japanese characters, whose glyphs are wide by design, it waits for 0.22 times. Letter-spaced headings can therefore come out as “H E A D I N G”.

Glyphs whose baselines agree within 35% of the font size form one line. With “join line breaks” on, end-of-line hyphenation such as “exam-/ple” is undone only when the joined word (“example”) appears elsewhere in the document or the second part is a plain suffix such as -tion or -ment; otherwise the hyphen is kept, so a compound split at a line end (“well-/known”) stays “well-known”. Chinese or Japanese lines are joined without a space.

Headers, page numbers and headings

Lines in the top and bottom 12% of each page are compared with digits replaced by #, and any line that recurs on at least half of the pages (minimum two) is removed as a header or footer. Stand-alone page numbers such as “- 12 -”, “12 / 40” or “Page 12” go too. A heading is a block at least 1.15 times the document's body size, no longer than three lines or 160 characters; heading sizes are ranked to give Markdown levels 1 to 4.

Worked examples

Two-column paper

Input
Gutter of about 18 pt; the file draws lines alternately left and right
Output
Whole left column, then whole right column

The gutter is wider than one em and continues across many lines, so it is taken as a column boundary.

Space detection

Input
Two 10 pt glyphs 1.5 pt apart
Output
Space inserted between Latin letters; none between Korean characters

The Latin threshold is 10 × 0.12 = 1.2 pt, exceeded by 1.5 pt. The CJK threshold is 10 × 0.22 = 2.2 pt, which it does not reach.

Running header in a 40-page report

Input
“Annual Plan 2026 | 3” at the top of every page
Output
Removed as a header

With digits replaced by #, every page has the same string, far more than the 20 pages (40 × 0.5) required.

How to use it

  1. Add a PDF; the tool reports columns per page and pages without text.
  2. Choose TXT or Markdown, line-break handling and header removal.
  3. Check the order in the preview, then copy or download.

Frequently asked questions

Copied text turns into random symbols.

The PDF lacks a correct ToUnicode map, or uses Type 3 fonts, so the glyphs have no recorded meaning. Extraction cannot fix that; run OCR on the pages instead.

The output is empty.

The pages are images — a scan or photos — with no text layer. Add one with the OCR tool, then extract again.

Table contents come out jumbled on one line.

This tool is built for running text. Use the PDF table extractor, which finds cell boundaries.

Can it keep bold and italics?

No. Only headings (by size) and lists (by marker) are carried into Markdown; font weight and style are not.

Related guides

Sources

Last reviewed:

Privacy and how data is handled