Extract Text From a PDF
Pull the text out of a PDF with its line and paragraph structure reconstructed, page by page or all at once. A PDF does not actually store lines — it stores glyphs at coordinates — so the structure is rebuilt from where the text sits on the page. When a document turns out to be a scan with no text layer at all, the tool says so plainly rather than reporting an empty result.
Use this without the search next time. Prathom Workbench puts Prathom's tools in your toolbar.
Add to Chrome — freeWhat it does
- Line and paragraph structure reconstructed from layout
- Extract selected pages or the whole document
- Optional page-boundary markers
- Detects scanned documents and explains them
- Copy to clipboard or download as .txt
How to use PDF to Text
- 1
Open the PDF
Drop the file in. It is parsed straight away and the page count shown.
- 2
Choose the pages
Leave the box blank for the whole document, or list pages and ranges to pull out just a section.
- 3
Extract
The text appears with a word and character count. Page markers can be turned off if you want a continuous block.
- 4
Copy or download
Copy the result to your clipboard, or save it as a plain .txt file.
How it works
The extractor asks the PDF engine for the text content of each page. What comes back is not text in any useful sense — it is a list of glyph runs, each with a transformation matrix saying where on the page it is drawn. A run might be a whole sentence, a single word, or one letter, depending entirely on how the producing software chose to emit it.
Turning that into readable text is three steps.
Grouping into lines. Runs whose baselines are within a couple of points of each other belong to the same line. The tolerance is not zero because superscripts, footnote markers, and inline formula fragments sit slightly off the baseline of the text around them — with an exact comparison, every footnote marker becomes its own line.
Ordering and spacing. Within a line the runs are sorted by horizontal position, and a space is inserted wherever the gap between one run's end and the next one's start exceeds a fraction of the character width. This step is necessary because a great many PDFs contain no space characters at all — words are simply positioned apart from one another, and a naive extractor returns everything jammed together.
Paragraph breaks. The vertical gap between consecutive lines is compared against the document's typical gap, and a blank line is inserted where it is substantially larger. The typical gap is a median rather than an average, because the distance from a header to the body and from the body to a footer are large outliers that would drag a mean up far enough to hide every real paragraph break.
What this cannot do, stated plainly
Scanned documents. If the PDF is images of paper, there is no text in it and no extractor can produce any. The tool detects this — when almost every page yields nothing, that is the signature — and says so, because an empty text box with no explanation looks like a bug.
Tables. A table in a PDF is text positioned in a grid, with no record that it is a table. The rows come out in roughly the right order and the columns run together. Anything beyond a simple two-column table needs a purpose-built extractor.
Multi-column layouts. Academic papers and newspapers are the hard case. Whether the runs arrive column by column or line by line across both columns depends on the producing software, and only the second is recoverable from position alone.
Reading order in general. The true reading order of a page is only present in a PDF if the producer tagged it for accessibility, and most do not. Everything above is a reconstruction from geometry, and it is right most of the time rather than always.
When you'd use this
Quoting from a document — pulling a paragraph out of a report without retyping it or fighting a PDF reader's selection.
Searching a document set with ordinary text tools once the text is out.
Feeding text into something else: a word counter, a translator, a summarizer, a spreadsheet.
Checking what is actually in a file. Because this reads the real text layer, it will show you text that has been covered by a black rectangle rather than properly redacted — which is a useful thing to check before sending a document out, and an uncomfortable thing to discover after.
Examples
A section of a report
The blank line before the paragraph was not in the file. It is inferred from the vertical gap between baselines being noticeably larger than the document's typical line spacing, measured as a median across the page so that a header and a footer do not distort it.
A scanned contract
Nothing is wrong here. The pages are photographs of paper, and there is genuinely no text in the file to extract. Reporting "0 characters" would be accurate and useless — what the user needs to know is that they have a scan and require optical character recognition instead.
Frequently asked questions
Why is my extracted text missing line breaks or in a strange order?
Because a PDF has no concept of a line. It contains instructions to draw runs of glyphs at particular coordinates, in whatever order the producing program emitted them, and any line structure has to be inferred from those positions. This tool groups runs by baseline and orders them left to right, which is right for ordinary prose. Multi-column layouts and tables are where it is least reliable.
Nothing came out at all. Is the file broken?
Almost certainly not — it is a scan. If a document was produced by photographing or scanning paper, every page is an image and there is no text layer, so a text extractor correctly finds nothing. You need optical character recognition, which reads the shapes of letters out of the picture. That is an entirely different operation and considerably slower.
Does the extracted text keep formatting like bold and headings?
No. The output is plain text, so bold, italics, font sizes, colors, and heading levels are all lost. That information exists in the PDF as font and styling instructions but there is nowhere to put it in a .txt file. If you need the formatting, you want a PDF-to-Word conversion, which is a much harder problem and not something a browser can do well.
Can I extract text from a password-protected PDF?
Not without the password. An encrypted document's content streams are genuinely encrypted, so there is nothing readable to extract. The tool reports this specifically rather than calling the file corrupt, because the two need different fixes — open it in a reader with the password and save an unprotected copy.
Is the document uploaded to be read?
No. The parsing engine runs as JavaScript inside this tab and its worker is served from this site rather than a third-party CDN, so no request is made to anyone when you open a file. Nothing about your document — not the text, not the filename, not the fact that you opened it — leaves your machine.
Further reading
- A Black Box Over the Text Removed Nothing At AllCovering words with a black rectangle is what every general-purpose PDF editor makes easy, and it is the single most common way confidential documents leak. The rectangle is drawn on top. The words are still underneath it, in the file, and any extractor will hand them back in full.
- Flattening a PDF Made It 14 Times Bigger and Deleted Every Searchable WordFlattening is what you do when a form must stop being fillable or a signature must stop being movable, and it is often described as if it just locks things down. It does more than that: it replaces the page with an image of the page, and everything that made the page text goes with it.
- OCR Recovered Every Character Flattening Had RemovedA flattened PDF has no text layer, which is often described as the text being lost. It is not lost, it is only no longer written down — the words are still drawn on the page, and reading them off a picture is exactly what OCR does.