← All posts

Why Text Copied Out of a PDF Is Full of Line Breaks

Copy a paragraph out of a PDF into Word and every line end has been cut. The whole thing falls apart into fragments. It looks like three instances of the same bad behaviour, but they have different causes and need to be fixed separately.

A PDF has no “paragraph”

Start with the root cause: a PDF has almost no paragraph structure at all.

A PDF is fundamentally a set of layout instructions. It does not record “here is a paragraph”; it records “place this character at coordinate (x, y)”. A line break is a layout decision made so the text fits the page width — it has nothing to do with the meaning of the text. But when you copy it out, that decision disguises itself as a newline, \n.

So every break you see comes down to one question: is this break the author’s intent, or the layout engine’s?

Three kinds of break, three different fixes

Breaks that look identical need completely different handling.

① Hard wrap (should be merged) The punctuation at the end of the line is incomplete and the previous line clearly has not finished. This is the most common case: replace the newline with a space (in English) or with nothing (in Chinese).

② Paragraph break (must be kept) A blank line already separated the two sentences. This is the author’s real intent to split paragraphs, and it must never be merged — gluing two paragraphs together is worse to fix than leaving the break in place.

③ Hyphenated line break (depends) English typography splits words at line ends with a hyphen (com- / pressed). Here you remove the hyphen and rejoin the halves — but only once you are sure it is a split word and not a word that legitimately contains a hyphen (e-mail, state-of-the-art).

The judgement rests on a few signals: whether both sides of the break are lowercase, whether the joined halves form a word that actually exists, and whether the break falls exactly at the line end. However tight the rules get, this one deserves a manual review path.

The CJK difference: the trap everyone misses

This part deserves its own section.

English is relatively safe to process because English separates words with spaces. Deciding whether two tokens should be read together or kept apart has a natural delimiter to lean on.

Chinese has nothing of the kind.

Look at a piece of Chinese that was processed incorrectly:

我们把图片压缩到指定体积这件事 做的心态其实很简单

Only a newline separates the two lines. Delete every newline blindly and you get:

我们把图片压缩到指定体积这件事做的心态其实很简单

Two sentences fused into one blob. Keep every newline blindly and you are back to the original pile of fragments.

So Chinese needs a different set of criteria, judged from the punctuation at the boundary:

  • Comma, enumeration comma, or no punctuation before the break, and the next line does not start a new paragraph → merge
  • Full stop, question mark, exclamation mark, or a closing quote before the break → likely a sentence boundary; lean toward keeping it, or handle it as sentence segmentation after merging
  • A blank line (two consecutive newlines) → definitely a paragraph, keep it

This is also why WordCheckly’s “fix PDF line breaks” behaves differently for Chinese rather than running one rule across both languages.

When you still need to check it yourself

Automatic rules handle the overwhelming majority of cases, but three categories deserve a human glance:

  1. Technical documents containing code — indentation and newlines are meaningful; any merging is destruction
  2. Poetry, block quotes, lyrics — the author broke the lines on purpose
  3. Pages mixing tables and footnotes — the copy order may not be the reading order

The tool takes care of 90% of the manual labour and leaves the remaining 10% of judgement to your eyes. That is far more honest than pretending to be fully automatic.

看看这些产品 →