How to Fix Text Copied From a PDF
You copy a paragraph out of a PDF, paste it into a document, and it arrives broken: every line ends in the middle of a sentence, words are split by hyphens that were not in the original, and something invisible in the text makes search behave strangely.
None of that is your fault. It is a consequence of how PDFs store text, and it takes about twenty seconds to fix.
Why PDF text copies so badly
A PDF is a description of where marks go on a page. It does not store paragraphs, sentences or even, in many cases, spaces. It stores something closer to: put these characters at this position, then these characters at that position.
When you copy, the reader has to reconstruct text from positions. It gets the individual lines right and the structure wrong, because the structure was never recorded in the first place. That is where the mid-sentence line breaks come from: those are real line endings from the printed layout, not paragraph breaks.
Fixing the line breaks
The fix is to join lines within a paragraph while keeping the blank line between paragraphs. Doing it by hand across a long document is miserable; doing it automatically takes one click.
Smart join is the mode you want. It also rejoins words that the original layout split across
a line with a hyphen, so inform- becomes
ationinformation rather
than staying broken.
The invisible characters
This is the problem people do not know they have. Copied text routinely carries characters that render as nothing at all:
- Soft hyphens (U+00AD) left over from justified text.
- Zero-width spaces (U+200B) used as line-break hints.
- Non-breaking spaces (U+00A0) that look exactly like normal spaces but are not.
- Byte order marks and direction marks from the document's encoding.
They cause real problems. Searching for a word fails because the stored version has a hidden character in the middle. A form rejects an email address that looks perfect. Two strings that appear identical compare as different in a spreadsheet.
The scan button shows you exactly which characters were present and how many, which is satisfying and also useful when you are trying to work out why something downstream is failing.
Smart quotes and dashes
Word processors and PDFs use typographic quotes (โ โ) and em dashes (โ). They look better in prose and break things in code, CSV files, URLs and command lines. The same cleaner can straighten them in the same pass.
When the PDF is a scan
If you cannot select any text at all, the pages are images โ a photograph of a document rather than a document. No amount of copying will get text out, because there is no text there to get.
You need OCR, which recognises the shapes of letters in the image. Google Drive does this for free: upload the PDF, right-click, and open with Google Docs. The result is imperfect but usually good enough to edit, and it will still need the line-break clean-up described above.
A repeatable workflow
- Copy the text from the PDF as usual.
- Run it through the invisible character remover with smart quotes straightening on.
- Run the result through smart join to fix the line breaks.
- Read the first and last paragraph. Automated cleaning occasionally joins two paragraphs that should have stayed apart, and that is where it shows.
Once it is clean, the text behaves like text again โ searchable, editable, and safe to paste anywhere.
Frequently asked questions
Why does text copied from a PDF break at every line?
A PDF stores positioned lines, not paragraphs. Copying gives you the printed line endings because paragraph structure was never recorded in the file.
What are the invisible characters in pasted text?
Usually soft hyphens, zero-width spaces, non-breaking spaces and direction marks. They render as nothing but break search, form validation and string comparison.
How do I copy text from a scanned PDF?
You need OCR, because a scan contains images rather than text. Google Drive will do it free: upload the PDF and open it with Google Docs.