File formats

How a PDF Stores Text And Why Copying Goes Wrong

The page renders from the font and copying reads a separate mapping. Nothing forces the two to agree.

7 min read

How a PDF stores text explains almost every problem people have with one. PDF files do not contain text. It contains instructions for putting marks on paper. PDF files hold no paragraphs in it, no sentences and no reading order, so getting text out is reconstruction rather than reading. Every complaint about copying from a PDF follows from that one fact.

The format was built to make a page look identical everywhere. It succeeded completely. Everything it is bad at is the price of that.

What a PDF File Actually Says

Strip a page down and the instructions read more like a printer than a document.

set the font to F1 at 11 points
move to position 72, 700
draw the glyphs 44 65 61 72
move to position 72, 686
draw the glyphs 53 61 6D

Nothing there says paragraph. Nothing says heading. Nothing says sentence. Nothing says this line continues the one above. There are marks and there are positions. The resemblance to a document exists only in your eye.

This is why a PDF looks the same everywhere. Nothing is being laid out when you open it. The layout already happened and the file records the result, which is exactly the property an HTML page does not have and exactly why the format won.

The Split That Explains Garbled PDF Copies

Here is the part almost nothing explains. It accounts for the strangest failure of the lot.

What gets drawn comes from the font. Which character that mark represents comes from a mapping stored separately in the file. Two different pieces of information. Nothing forces them to agree.

What you see

From the font
glyph 0044
  draw this shape

the page shows
  a capital D

Correct, always. The shape is in the file and it renders.

What you copy

From the mapping
glyph 0044
  means U+0044

missing or wrong
  the copy is
  whatever it says

Optional. Producers can omit it. Some subset fonts leave it broken.

Display uses the left. Copying uses the right. A perfect looking document with a broken mapping pastes as symbols. Nothing about the page hints at it.

This is the same shape of problem as character encoding. Bytes that need a table to mean anything. A table that may be absent or wrong. The difference is that a PDF renders correctly regardless, so the fault is invisible until somebody copies something.

Read next Character Encoding And Why Your Text Arrives Broken The same shape of fault in a format that cannot hide it the way a PDF can.

Four PDF Text Failures With One Cause

The fix it articles list these as separate problems. They are one design decision seen four ways.

What you getWhat is missing
Nothing selects at allText objects. It is a picture of a page
Symbols and boxesThe mapping from glyph to character
A line break after every lineParagraphs. There were never any
Words in the wrong orderReading order. The file has drawing order
Missing spaces between wordsSpaces. Gaps can be position changes instead
Ligatures pasted as one odd characterNothing. fi really is one glyph

The spaces row surprises people most. A PDF need not store a space character between words. It can simply draw the next word further along, so the gap you see is a position rather than a character. Extraction has to decide how wide a gap counts as a word break. That is a guess made per file.

Why Scanned PDFs Are a Different Problem

A scanned PDF is not a PDF with difficult text. It holds none at all.

The file holds an image of a page. To a reader it is a photograph. The letters in it are no more text than the letters on a photograph of a street sign.

  1. Telling them apart Zoom in hardReal text holds its edges at any size, because it is drawn from a font. An image softens, having a fixed number of pixels
  2. What OCR does Guesses from shapesLooks at the marks, decides which characters they resemble, writes that guess in as a text layer over the unchanged picture
  3. Why it is never perfect Resemblance is not certaintyA one and a lowercase l look alike. So do rn and m. The errors are visual confusions rather than storage faults
OCR adds text that was not there rather than recovering text that was. That is worth stating plainly, because it decides how much you should trust the result of a search across scanned documents.

A searchable scan is two layers. The picture people read. A text layer nobody sees, holding a machine's opinion of the first. Where a search across scanned archives comes back empty, the document may well be there and the guess may simply have been wrong.

The Kind of PDF That Does Extract Cleanly

There is a version of PDF built to answer all of this. Most files are not it.

A tagged PDF carries a structure layer alongside the drawing instructions. It records what is a heading, what is a paragraph, which cells belong to which table and what order any of it should be read in. Exactly the information the base format leaves out.

Ordinary PDFTagged PDF
Marks and positionsMarks, positions and structure
Reading order guessedReading order recorded
Tables become loose textTables stay tables
Screen readers struggleScreen readers work

Tagging was built for screen readers and it fixes extraction by accident. Where a document has to be readable by a screen reader it also extracts cleanly, which is a rare case of an accessibility requirement paying for itself in an unrelated place.

Getting Text Out of a PDF With Fewer Surprises

  1. Establish which kind you have first. Magnify the page hard. Sharp means text objects. Soft means an image. The two need entirely different approaches.
  2. Try selecting a single word before doing anything else. If it highlights and pastes correctly, the mapping is intact and the rest is a formatting problem rather than a data one.
  3. Expect to rejoin the lines. No extraction preserves paragraphs a PDF never held. Plan for a pass that joins lines and keeps the real breaks.
  4. Check a column layout deliberately. Copy a paragraph from a two column page. Where it interleaves the columns, the drawing order and the reading order disagree and no setting fixes that.
  5. Treat a copy restriction as a preference. It asks the reader not to allow copying and changes nothing in the file. A tool that ignores the request reads the text objects exactly as before.

Where the extraction has to be right rather than roughly right, read the result rather than the original. A person comparing the extracted text against the page finds every one of these faults in a couple of minutes. No automatic check finds them at all.

The first of the five checks above needs no software beyond what you already have. Zoom to four hundred percent and the answer is on screen. Where the file has to be examined more closely than that, our PDF viewer shows whether a page carries text objects at all, which is the one question that decides everything after it.

Structural behaviour checked against the referenced articles and the published PDF specification in August 2026.

Questions People Ask

7 questions, answered in full below.

Why does copied PDF text come out as symbols?

Because what a PDF draws and what it says a mark means are stored separately. The page renders from the font and copying reads a mapping beside it. Where that mapping is missing or wrong, the page looks perfect and the copy is nonsense.

Why does every line become its own paragraph?

Because a PDF has no paragraphs. It has positioned blocks of characters. Where one line ends is a fact about the page rather than about the sentence. Anything reassembling paragraphs is guessing from the spacing.

Why can I not select text at all sometimes?

Because there is none. A scanned document holds an image of the page, so there are no characters to select. Zooming in settles it. Text stays crisp at any size and a picture goes soft.

What does OCR actually do?

It looks at the shapes and guesses which characters they are, then writes that guess into the file as a text layer. The picture is unchanged underneath. That is why OCR output has errors and why they are errors of resemblance rather than of storage.

Why does copied text come out in the wrong order?

Because the order stored is the order things were drawn, which need not match the order they are read. A two column page might be stored column by column. It might run line by line across both. It might follow whatever order the producing software chose.

Does a copy restriction actually stop anything?

It asks the reading software not to allow copying. The text objects are unchanged and software that ignores the request finds them. It is a permission rather than a protection, which is a distinction worth knowing before relying on it.

Is there a kind of PDF that extracts cleanly?

A tagged one. Tagging adds a structure layer recording what is a heading, a paragraph, a table cell and what order to read them in. It exists mainly for accessibility. Most PDFs do not have it.

Sources

Where the figures and behaviour described above were checked.

  1. PDF Wikipedia
  2. Optical character recognition Wikipedia
  3. Glyph Wikipedia