A PDF does not contain sentences, which is why extracting text means rebuilding them
Open a PDF in a text editor and you will not find the sentences you see on the page. A PDF is a set of drawing instructions. Each instruction says, in effect, put these glyphs in this font at this point on the page. The program that wrote the file decides how to cut the text into those instructions, and most cut it into short runs: a word, part of a word, a stretch of letters that share a font and spacing. Nothing in the file says that two runs belong to the same word, the same line or the same paragraph. That knowledge only exists in the picture the instructions draw.
So extraction is reconstruction. This tool asks pdf.js for every run on a page, with its text, its position and its size, and rebuilds the reading text from the geometry. Runs whose baselines sit within half a line height of each other are treated as one line; that tolerance is what keeps a raised superscript or a footnote marker on the line it belongs to instead of giving it a line of its own. Within a line, the runs are sorted left to right.
Spaces are the subtle part, because very often there are none. Many PDF writers never store a space character at all. They simply start the next word a little further along. Here a space is inserted when the gap between two runs is wider than about a third of a character in the preceding run, measured from that run’s own width. A narrower gap is kerning inside a word, which is why a word split across two runs comes back whole rather than as “Hel lo”. Lines are then stacked from the top of the page down, and when the distance between two baselines is more than one and a half line heights, a blank line marks a new paragraph.
This approach has a limit worth knowing about. Reading lines across the full width of the page is correct for letters, reports and most books, and wrong for anything set in columns. A two-column paper comes out with the first line of the left column followed by the first line of the right one. Recovering columns needs layout analysis: finding the vertical channel of white space between them and reading each column separately. That is a guess about the page, and a wrong guess scrambles a document that was fine, so the tool does not attempt it and says so instead.
The other limit is absolute. A scanned page is a photograph wrapped in a PDF, and a photograph has no runs to ask for. When every page comes back empty, the tool says the file is probably a scan rather than offering you an empty download. Recognising letters in a picture is a different job, optical character recognition, and an honest empty answer is better than a confident wrong one.