← Blog
By Rob Stephan

How to Fix Text Copied From a PDF

Every line breaks in the wrong place, words are split by hyphens, and the spacing is strange. Here is why that happens and the two-step fix.


Copy two paragraphs out of a PDF and paste them anywhere, and you get a column of short fragments — one line ending in "inter-", another breaking mid-sentence, and spacing that looks nothing like the original.

Nothing is broken. It is doing exactly what it was asked.

Why it happens

A PDF is a description of a printed page, not a document in the sense a word processor means. It stores where each line was placed, not where the sentences end. When you copy, you get the line breaks of the page — a break every seventy characters or so, wherever the typesetter happened to run out of room.

The same goes for hyphens. "International" split across two lines is stored as "inter-" and "national", because that is how it was printed. And the spacing between words is often a series of positioning instructions rather than space characters, which is why some PDFs paste with double spaces and others with none.

Step one: rejoin the lines

Use remove line breaks. The job is not simply deleting every newline — that would run your paragraphs and bullet lists into one block. What you want is to tell structure from wrapping:

  • A blank line means the writer ended a paragraph. Keep it.
  • A line starting with a bullet, a number or an indent is a list item. Keep it on its own line.
  • Everything else is a sentence that ran out of room. Join it to the line before.

That is what the tool does by default, and it rejoins hyphenated words while it is there — so "inter-" and "national" become "international" rather than "inter- national". It also tells you how many lines it joined, which is a quick check that it found the paragraphs you expected rather than inventing new ones.

Step two: clean what is left

PDF text usually carries more than bad line breaks. Run the result through the text cleaner to deal with:

  • double spaces after full stops, a hangover from typesetting conventions
  • non-breaking spaces, which look like ordinary spaces but are not
  • trailing spaces on every line, left over from the page layout
  • the occasional invisible character from the document's own encoding

The cleaner reports what it fixed, so you can see what the source actually contained.

You do not need to copy and paste between the two: use Send to on the result of the first tool and the text arrives in the second.

When the PDF is scanned

If the PDF is a photograph of a page — a scan, or a document produced by a copier — there is no text to copy at all, and nothing here will help. You need optical character recognition first. The giveaway is that you cannot select individual words: the cursor draws a box over the whole page instead.

Keep the result

Once the text is readable, you usually want it somewhere other than your clipboard. Any tool here can hand its result straight to a ShareText note with a link you can send, or download it as a plain text file.

Related tools

  • Remove line breaks — rejoin wrapped lines, keep paragraphs and bullets
  • Text cleaner — spaces, blank lines and invisible characters, with a report
  • Word counter — check the extract is the length you expected

Written by

Rob Stephan

A dad, husband and a software engineer, I love building solutions to make life easier.