Copy a paragraph out of a PDF and paste it into an email, and the result is often not quite the paragraph you saw. Every line ends in a hard break, words cut by a hyphen stay cut, two columns come out interleaved, and now and then the whole thing turns into a row of symbols. None of that is a bug in the reader you copied from. A PDF was designed to make a page look the same everywhere, and it stores what is needed to draw the page, not what is needed to read it. Words, lines and paragraphs are things an extractor has to work out again from where the letters sit.
A PDF Stores Letters at Positions, Not Sentences
The text on a PDF page lives in the page's content stream, a list of drawing instructions. Two operators do most of the work: Tj draws a string of characters starting at the current point, and TJ draws several strings with a number between each pair that nudges the next one left or right, in thousandths of the font size. Other operators move the current point to a new line or anywhere else on the page. A generator is free to draw a sentence as one string, as one string per word, or as one letter at a time, and to draw lines in any order it likes.
What the stream does not need to contain is a space character. A word gap can be an actual space, or just a TJ adjustment that moves the next word along, and both look identical on the page. So an extractor measures the gap between the end of one run of letters and the start of the next, and inserts a space when it is wider than a fraction of the font size. Get that threshold wrong and you get either wordsruntogether or l e t t e r s spread apart, which is exactly what tightly kerned headings and justified text with wide gaps tend to produce.
From Character Codes to Letters
The strings inside Tj and TJ are not text in any modern sense. They are character codes, and each one only means something together with the font it is drawn in: the font maps the code to a glyph, the shape that gets painted. To turn codes back into letters, a reader needs a second map from code to Unicode. Section 9.10 of ISO 32000-1, the PDF standard, describes where that comes from. For fonts with a standard encoding the reader can work it out from the glyph names, and for everything else the font should carry a ToUnicode CMap, a table that lists the Unicode text for each code.
The trouble starts with embedded subset fonts. To keep files small, a generator embeds only the glyphs a document uses and often renumbers them 1, 2, 3 in the order they first appear. If it then leaves out the ToUnicode table, the page still renders perfectly, because the font knows which shape each number is, but nothing in the file says that code 7 is the letter e. Copy and paste, search and every extraction tool all get the raw codes, which show up as symbols or unrelated letters. No setting fixes this, since the information is simply not in the file. The fallback is OCR on a picture of the page.
What Goes Wrong and Why
Common faults in text copied or extracted from a PDF, what causes each one in the file, and what helps.
| What you see | Cause in the file | What helps |
|---|---|---|
| A line break in the middle of every sentence | Each printed line is drawn separately and nothing marks where a paragraph ends | Join wrapped lines back into paragraphs |
| Words split as infor- mation | The hyphen was drawn as an ordinary hyphen, not marked as a line-end break | Rejoin a hyphen at a line end when a lowercase letter follows |
| Words run together, or letters spaced apart | Word gaps are position shifts rather than space characters | Better gap detection in the extractor; nothing in the file to fix |
| Symbols or random letters instead of text | Embedded font with custom codes and no ToUnicode table | OCR on an image of the page |
| No text at all | The page is a scanned image | OCR, or a searchable copy from the scanner software |
| Columns mixed together, headers in the middle | Text drawn in an order different from the reading order | A tagged PDF, or copying one column at a time |
Reading Order Is Whatever Order It Was Drawn In
An extractor that reads a page without guessing returns the text in content-stream order. For a document exported from a word processor that is nearly always the reading order: the header, the body top to bottom, the footer. Desktop publishing layouts are less tidy. A newsletter put together from text boxes can draw them in the order they were created, a footnote can be drawn before the paragraph that points to it, and a page number can come first because the master page was drawn before the content.
The standard does offer a fix. A tagged PDF, described in section 14.8 of ISO 32000-1, carries a structure tree that marks headings, paragraphs, lists and tables and puts them in logical order, independent of the drawing order. It exists mainly for screen readers, and it is what PDF/UA, the accessibility profile, requires. Office suites write tags when asked to export an accessible PDF, but many generators skip them, and a file without tags leaves the extractor with positions and drawing order alone.
Hyphens, Ligatures and Other Small Lies
Some of what you see on a page is typography, not text, and a careful generator marks the difference. Many do not.
Soft hyphens
Unicode has two hyphens for this job. U+002D is the ordinary hyphen that belongs in the word, and U+00AD, the soft hyphen, marks a break that exists only because the line ended. A generator that writes the line-end hyphen as U+00AD lets any extractor drop it safely. Most write U+002D, and then the extractor has to guess: a hyphen at a line end followed by a lowercase letter is almost always a word split, but not always, since well-known can break right at its own hyphen.
Ligatures
Good typesetting replaces f followed by i with a single joined glyph. Unicode has code points for the common ones, such as U+FB01 for fi, and a font with a correct ToUnicode table maps that glyph to the two letters f and i. When the mapping points to the ligature code point instead, the pasted word looks right but search for find fails to match it, which is why extractors normalise these characters back to plain letters.
Replacement text
A generator can attach the text a passage really means through an ActualText entry, covered in section 14.9.4 of ISO 32000-1. It is the clean way to say that a hyphenated pair of lines reads as one word, or that a drop cap and the rest of the word belong together. Readers that support it, Acrobat among them, copy the replacement instead of what was drawn.
Spaces that are not spaces
Justified text widens the gaps between words, and some generators draw each word separately with no space at all between them. Wide tracking in headings does the opposite, pushing letters far enough apart to look like word gaps. Both leave the extractor working from distances, which is why a heading in widely spaced capitals is the part of a PDF most likely to paste badly.
Why a scan you can search still has no visible text
When scanner software runs OCR and saves a searchable PDF, it keeps the scanned image as the page and lays the recognised text over it in text rendering mode 3, which the PDF standard defines as neither filled nor stroked: the letters are present, positioned over the words in the picture, but invisible. That is why you can select and search such a scan. It also explains the odd results you sometimes get from it. The text is only as good as the OCR that produced it, so a smudged page yields misread words that look perfectly correct on screen, because what you see is the picture, not the text you copied.
Get the text out of a PDF
Copy it or save it as .txt, with wrapped lines joined back into paragraphs and scanned pages pointed out.
How Lines Become Paragraphs Again
A page of body text has a steady rhythm: every line sits the same distance below the one above it, the line pitch, often about 1.2 times the font size. A new paragraph usually breaks that rhythm with extra space, an indent, or both. An extractor that wants paragraphs back measures the pitch the page uses most and treats a noticeably larger gap as a paragraph break. Going back up the page counts as a break too, since it means the text has moved to a new column or a box placed elsewhere.
That works well for ordinary documents and fails in predictable places. A paragraph that starts with only an indent and no extra space runs into the one before it. Text set with generous spacing everywhere, such as a double-spaced manuscript, has nothing to stand out against, and headings with the same spacing as body text merge into the paragraph below. Joining the lines of a paragraph into one is the riskier step, which is why it is best left as an option: right for a report you are pasting into Word, wrong for an address block, a poem or a table, where every line break means something.
Frequently Asked Questions
Related Tools
Keep Reading
Turning a PDF Page Into an Image: DPI, Size and Format
A PDF page has inches, not pixels, so the DPI you choose sets the image size. What each resolution is for, why JPG smudges text, and why Word gets the size wrong.
Splitting a PDF: Why the Parts Weigh More Than the Whole
One shared font becomes twenty copies, a contents page can drag the whole document along, and edit history quietly drops out. Where the bytes go in a split.
Word Count Targets: What Editors, Platforms and Google Expect
Two counters can disagree by five percent on the same paragraph. Here is how counting actually works, and the targets worth writing to.
How Diff Works: The Algorithm That Decides What Changed
Myers walks a grid one edit at a time, and Git has run it since 1986. Why the shortest diff is not always the clearest, and what makes one look wrong.