Skip to content
Utilboxes

How to fix text copied from a PDF: broken lines, odd spaces and quotes

Text pasted from a PDF or web page arrives with a break after every line, strange spaces and curly quotes. Here is why, and how to clean it in seconds.

Published

Tools for this job: Text Cleaner · PDF to Text · Character Counter

Copy a paragraph out of a PDF and paste it into an email, and it arrives as a column of short lines, each ending where the line ended on the page. Text from web pages and word processors brings its own invisible extras. None of this is visible until it causes trouble.

Why PDF text breaks into lines

A PDF does not store paragraphs. It stores lines of text at fixed positions on the page, so copying gives you each line followed by a line break. A paragraph of ten lines becomes ten separate lines when pasted.

Clean it step by step

  1. Paste the text into Text Cleaner.
  2. Turn on joining broken lines. Single line breaks are merged into flowing paragraphs, while blank lines — real paragraph breaks — are kept.
  3. Turn on the other fixes you need, watching the preview after each one.
  4. Copy the result.

Each fix is a separate switch, so you change only what you mean to. The text is cleaned in your browser.

The invisible problems

  • Non-breaking spaces look like ordinary spaces but stop text from wrapping and break searches.
  • Zero-width characters have no appearance at all, yet make two identical-looking words compare as different.
  • Runs of extra spaces, left over from layout.
  • Smart quotes and dashes — curly quotation marks and long dashes that word processors insert. They look good in prose but break code, CSV files and data imports, and they can push a text message over its character limit.

Hyphenated line ends

Justified PDFs often split words across lines with a hyphen: “docu-” on one line and “ment” on the next. After joining lines, search for a hyphen followed by a space to find these and remove the hyphen. Be careful with words that really are hyphenated.

Getting all the text from a PDF

For more than a paragraph, copying from a viewer is tedious and often scrambles columns. PDF to Text extracts the whole document page by page, with its own option to join lines into paragraphs. If nothing comes out, the PDF is a scan — a picture of text — and needs OCR instead.

Text from web pages

Pasting from a web page can bring formatting, links and invisible characters with it. Pasting as plain text — Ctrl+Shift+V in many programs, or Cmd+Shift+Option+V on a Mac — avoids most of the formatting; the cleaner handles the characters that remain. If you have copied raw HTML, the cleaner can strip the tags and turn entities such as & back into ordinary characters.

Check the length

Cleaned text is often shorter, because extra spaces and invisible characters are gone. If the text is going somewhere with a character limit, count it afterwards with the Character Counter.

Tools used in this guide

More tools for this job

All guides