Why does text copied from a PDF break at the end of every line?

By the Osmanth team at Osmanth Docs · Published 2026-10-13

A PDF records where each piece of text sits on the page, not where a paragraph begins or ends. So a copy keeps the line breaks you see on the page. On 2026-10-13 we converted a two-page report to text. The raw text had 77 lines. The cleaned text had 16, with paragraphs joined and page headers removed.

What did we convert?

In our test we ran two files with invented content. The first is a two-page report with a running header and a "Page 1" or "Page 2" footer line, three numbered sections, a bullet list, a table, a figure caption and one long paragraph. The second is a one-page paper in two columns, with 24 numbered sentences, so that any mix-up in order would show. We uploaded both to PDF to Text on osmanthdocs.com. The tool gives two files for each: a raw text file, and a cleaned text file.

What we compared Raw text file Cleaned text file
Report: non-empty lines 77 16
Report: running header and "Page n" lines The header twice and "Page 1" and "Page 2" None
Report: page markers --- page 1 --- and --- page 2 --- None
Report: a sentence at the end of a line Broken mid-sentence, such as "...invented for this" and then "guide." One line
Report: the table Cells separated by spaces Cells separated by tab characters
Report: the title As written In capital letters
Two columns: non-empty lines 52 5
Two columns: the 24 sentences All 24, in order All 24, in order, as one paragraph per column

The report was labelled "Looks good". In the report, the bullet character was kept in both the raw and the cleaned file.

Why does a copy break at every line?

The documentation of the open-source library pdf_elixide says that a PDF page stores positioned glyphs, not lines or paragraphs, so any plain-text output has to infer structure. It describes two outputs. One keeps the visual rows it finds and can rejoin some words split across lines. The other infers paragraphs and reading order, detects columns and usually puts each paragraph on one line. The two can differ on untagged pages of prose and match on simple pages.

The pdftotext program from the Poppler project has the same split. Its manual page says that the default mode tries to undo columns and hyphenation and outputs text in reading order, that -layout keeps the physical layout as best it can, and that -raw keeps text in the order of the page's content stream. It calls -raw a hack that often undoes column formatting, and says it is no longer recommended.

What went right, and what did we not manage to show?

  • Paragraphs were joined. The long paragraph came out as one line, and so did each column of the two-column paper.
  • Page furniture was dropped. The running header and the page-number lines were not in the cleaned file.
  • Order was kept. All 24 sentences appeared in order, down the left column and then the right.
  • We could not show a jumbled order. In the raw file the 24 sentences were also in order. We built the file one column at a time, so its content stream already ran in reading order. A PDF made differently could come out mixed up in raw mode, and our file does not test that.
  • Each column became one block. "Sentence 01" to "Sentence 12" form a single paragraph, so a reader who wants one sentence per line will need to split them.

What should I check after converting?

  1. Search for a sentence that crosses a page break and see that it is whole.
  2. Read the start of each section to check that no heading was joined to the paragraph below it.
  3. If the PDF has columns, read down one column and then the next.
  4. For a table, use PDF to Excel instead. Text keeps tab characters between cells and nothing more.

What are the limits?

This is two files, so it shows what the tool did here and not how often it will be right. We did not test scanned pages, text in languages other than English, or very long documents. A scanned PDF is a picture of a page and needs OCR first; see how to extract text from a scanned PDF.

Your PDF is uploaded to our servers, processed with open-source software and deleted when processing finishes. The results stay for 60 minutes.

Sources

  1. pdf_elixide documentation: Text extraction (page is for version v0.22.0, no date shown, checked 2026-10-13)
  2. Debian manual page for pdftotext 3.03, poppler-utils 22.12.0 (no date shown, checked 2026-10-13)

More guides