Copy text from PDF: fix broken lines and scans

You copy a paragraph from a PDF and get six short lines, a page number and half a sentence from the next column. To copy text from PDF files cleanly, first work out whether you are extracting existing characters or recognising a scanned page. Then check paragraph boundaries and reading order before fixing formatting. Use this guide to find the cause. It also explains when trying to copy again will not help. Choose a better route based on the source. Blind find-and-replace tricks can hide the real problem.
What happens when you select a sentence?
Open the PDF in a trusted viewer and drag across one normal sentence. Paste into a plain-text editor. If the words are right but the line breaks are awkward, the text layer is probably useful. If selection follows odd fragments or returns unrelated characters, the underlying representation may be unusual. If nothing selects, the page may be an image or access may be restricted.
Try a second page with a different layout. A file can combine digital text, scanned pages and images with text inside them. The cover tells you very little about a dense appendix. Note which pages fail. Change the method for those pages first. Repeating the whole export may teach you nothing new.
The pypdf documentation explains the central problem as “Missing Semantic Layer”. Positioning words on a page does not necessarily identify paragraphs, table cells or headings. That is why correct letters can arrive in an unhelpful order. Treat layout recovery as its own step, not simply as a spelling problem.
Diagnose the symptom before changing the text
Do not immediately remove all line breaks. That can join list items, table rows and section headings into prose. It can also erase a distinction the original author intended. Instead, compare one troublesome passage with the page and decide what kind of break you are seeing. A wrapped sentence may need joining. A new numbered step should stay separate.
Table: a PDF copy diagnosis sheet. These are common symptoms and suggested checks, not a test result for a particular viewer.
| Symptom | Possible cause | Useful next check |
|---|---|---|
| Every visible line becomes a new paragraph | Physical line positions exported | Compare punctuation at line ends |
| Words jump between columns | Reading order lost | Extract one column separately |
| No selectable text | Scanned page or restriction | Inspect source type and permissions |
| Wrong characters despite clear display | Text encoding or old OCR layer | Compare a fresh region capture |
| Page heading inside a sentence | Header mixed with body | Check the page break in the source |
A table like this narrows the next action. It does not identify the cause with certainty. For example, missing text could reflect an empty selection, a scan or a restriction. Check the file and viewer before deciding that the extractor is broken. Work on an exported copy. Keep the source unchanged.
How do I copy PDF paragraphs without broken lines?
Start with a small passage. Paste it into an editor where line breaks are visible. Compare the last word on each line with the first word on the next. Join lines that continue the same sentence, while preserving genuine paragraph breaks, lists and headings. Re-read the joined paragraph to ensure a sidebar or footer has not slipped into the middle.
Hyphenation needs judgement. A printed line may split one word in two. You may need to join it and remove the hyphen. A compound term may need the hyphen kept. Do not apply a global rule that removes every hyphen followed by a line break. That can change product names, mathematical signs and ordinary words. Review ambiguous examples against the page.
For repeated work, use a document reader that reconstructs paragraphs and gives you a preview. Lass0's PDF text workflow can render extracted structure as plain text or rich text, depending on the destination. For a notes repository, the Markdown conversion guide adds heading and table checks to the same basic review.
A worked example: the two-column briefing
Imagine an illustrative briefing with a left column explaining a problem and a right column listing recommendations. A direct copy mixes the first line of each column. You get grammatical fragments that look almost like a summary. It is tempting to tidy them until they read smoothly. That would hide the copying error. It could change the argument too.
Instead, select the left column alone and check the sequence. Then select the right column with its heading. Preserve a note that they are separate sections. Compare the opening and closing sentence of each. If the page contains a caption between them, decide where it belongs from the visual source. Do not let a converter's chosen order become an accidental editorial decision.
Now paste into the final app. A word processor may offer a choice between keeping source formatting and plain text. Choose based on what you need, then inspect again. Correct extraction can still look odd after the destination applies its own styles. A local intermediate note helps you separate source problems from paste behaviour.
What if the PDF is a scan?
A scan needs OCR to turn the page image into characters. Improving the source may matter more than changing the output format. Straighten a skewed page, avoid a tiny preview and seek a higher-quality original when the strokes are blurred. Do not assume that increasing the file size or resaving as another image format adds missing detail.
OCRmyPDF's documentation describes adding searchable text layers to scanned PDFs. That is useful when you want to keep the PDF as the main document. A separate text or Markdown export is more suitable when you need to edit the content elsewhere. Choose the output first, rather than treating every OCR tool as interchangeable.
Check names, dates, references and amounts more closely than ordinary connecting words. A recognised sentence can sound right while containing a wrong digit. Our OCR quality checklist suggests a small set of representative samples and a way to record errors without claiming universal accuracy from one successful page.
Can I copy text from a protected PDF?
Respect the document's access controls and the rights attached to it. If a file is locked, ask its owner for help. The same applies if the viewer blocks copying. Request an approved export or a source you can read. Do not treat OCR as permission to bypass a restriction. There may be a legitimate version in Word, HTML or plain text that is both easier to use and more suitable for your purpose.
A damaged file is a different issue. Try reopening a local copy in a supported viewer and confirm that the page itself renders correctly. If it does not, obtain a fresh copy from the official source. Repeatedly transforming an incomplete download can create more confusing symptoms while moving you further away from a trustworthy original.
Finish with the destination in mind
For a ticket, plain text is usually enough. For an email, rich text may preserve a useful list. For a spreadsheet, check tabs, numbers and cells using the table conversion guide. Do not force every destination through Markdown merely because that export looks organised in the preview.
Keep the original filename or a source reference beside a substantial excerpt. A paragraph may include “for internal use only” or “excluding archived accounts”. Keep those conditions with the text. The best copy is the one that preserves meaning after it leaves the PDF. Try a representative non-sensitive file, inspect its difficult pages and only then apply the same workflow to a larger batch.
Questions, answered
Why do PDF paragraphs paste with a break on every line?
The export may preserve physical line positions rather than logical paragraphs. Join only genuine sentence continuations and keep lists and headings separate.
Why can I see PDF text but not select it?
It may be part of a scanned image, or access may be restricted. Inspect the source type and obtain an authorised extract when needed.
Should I OCR a PDF that already has selectable text?
Usually try the existing text first. OCR adds recognition uncertainty, though a fresh capture can help diagnose an unusable or inaccurate text layer.
Put it into practice.
Explore the related Lass0 workflow or download the app to try it with a non-sensitive example.