Skip to main content
PixelTools
All articles
Guides5 min readby the PixelTools team

PDF Copy Paste Has No Spaces: Cause and Fixes

Words run together when you copy text from a PDF? The file stores word positions, not spaces. See the cause, quick fixes, and when you need OCR.

Why Does PDF Text Have No Spaces When You Copy It?

PDF text loses its spaces because many PDFs place each word at a fixed x/y position instead of storing one continuous string. To create a visual gap, the software moves to the next position and never writes a space character, so extraction tools glue the words together.

A PDF does not store text the way a Word document does. Many files draw each word, or even each letter, at its own coordinates. On the page it looks exactly right. But your browser's copy and paste, a script, or an extraction tool looks for space characters, not gaps in coordinates. If the data holds no real space, the tool has to guess, and a tool that does not guess returns the words fused together.

Why Some PDFs Do This and Others Don't

Whether a PDF stores real spaces depends on the software that generated it, so the problem is inconsistent. Simple PDFs from a word processor usually keep real spaces and extract cleanly. Justified text is a common trigger, because the renderer is already repositioning words to fill the line and may skip the space character.

Tables and multi-column layouts are another frequent culprit, since each cell is often placed independently with nothing linking it to its neighbor. Figure captions, PDFs exported from design tools, and older printing software follow the same pattern. You cannot tell by looking at a PDF whether it will extract cleanly, so you have to try it.

How Our Extractor Decides Where a Space Goes

Pixeltools' [Extract Text from PDF tool](/pdf-to-text) reads each positioned text run with PDF.js, then inserts a space when the horizontal gap between two runs on the same line is larger than 20% of the text's font height. It does not wait for the PDF to contain a space character, which is why it can recover spacing some files never encoded.

It also will not add a second space if either run already has whitespace at the join. A larger vertical jump starts a new line, and more than about 1.6 times the font height starts a new paragraph. Everything runs locally in your browser, so the file is not uploaded. Because the rule is a threshold, it is also the source of the edge case in the next section.

The Edge Case: Tightly Set Text Can Still Run Together

Text set with tight letter or word spacing can still come out joined, because a gap of 20% of the font height or less is treated as part of one word. A gap smaller than that is read as normal spacing between letters, such as a kerning pair, not as a word break.

So if a designer tightened tracking, or a producer squeezed a line to fit, the visible word gap may fall under the cutoff and the words fuse. The fix in that case is not another pass of the same tool. Try a different viewer's copy, re-export the file with normal spacing if you control it, or run [OCR PDF](/ocr-pdf), which reads the shapes on the page and does not depend on gap sizes. The threshold also only compares gaps between separate runs, so it cannot split words inside a single run.

If It's a Scanned PDF, the Fix Is OCR, Not Extraction

For a scan or a photo of a document, the fix is OCR, because there is no text layer to extract. What looks like text is a picture of text, so no extraction method can recover spacing that was never stored.

Our extractor detects this case: if every page comes back empty, it tells you the PDF is a scanned or image-only document instead of handing you a blank .txt file. Pixeltools' [OCR PDF tool](/ocr-pdf) then re-reads each page as an image in your browser and rebuilds a text layer with real spaces. Note that OCR output can have its own spacing errors on skewed or low-resolution scans, so check a sample before trusting a long document.

Try Another Viewer Before You Blame the File

If copy and paste fails in one app, test the same passage in another viewer first. Users report that a file copied badly in one PDF viewer or browser extension can copy correctly in Adobe Acrobat Reader, Chrome's built-in viewer, or Preview. Linux viewers built on the Poppler library have been reported to add extra spaces in some files, while other apps handle the same files fine.

That tells you the data may contain enough information and one viewer is guessing badly. Some PDFs also carry an ActualText entry meant to override what gets copied, and not every viewer honors it. Download the file and open it in a desktop app if you are reading it inside a web page or an embedded viewer, then paste into a plain-text editor to see the real result without autocorrect hiding it.

Manual Cleanup When You Still Have Garbled Text

If some words are still joined, find-and-replace with a regular expression catches the predictable cases. Search for a lowercase letter directly followed by an uppercase letter, which finds joins like "wordNextword", and insert a space at each match.

This will not catch two lowercase words running together, so you will still read through and fix some by eye. That is realistic for a page or two. On a 50-page report it is not, so re-extract with a different tool or viewer first and only hand-fix what is left. If the original Word or design file is available, extracting from that will always beat working around a PDF's quirks.

Frequently asked questions

Try it on PixelTools — free, no upload needed