PDFGami Logo
v2.25.0
Free · Secure · Browser-Only

Why Text Copied From a PDF Comes Out Scrambled — and How to Fix It

By AIC Innovation·Published ·7 min read

You drag across a page, press Ctrl+C, paste — and get the left column and the right column woven together line by line, words with no spaces between them, or an empty clipboard. None of that is your viewer misbehaving. It is what a PDF actually is, and once you know that, each of the three failures has a different and fairly simple fix. This guide explains the cause, then walks through extracting the text properly with PDFGami's PDF to Text tool, which does the work in your own browser.

Open the PDF Text Extractor

Why copied PDF text comes out scrambled

A word processor document stores a stream of words with structure around them: this is a heading, this is a paragraph, this paragraph comes after that one. A PDF stores something much closer to printing instructions. Its content is a list of drawing commands, and the text ones say roughly put these glyphs at this position in this font at this size. That is all. There is no paragraph, no line, often not even a word — just a few hundred or a few thousand positioned runs of characters per page.

The page looks perfect because the positions are exact. The trouble starts the moment something tries to read it back as prose, because the only order the file gives you is the order the runs were written in — and that is entirely up to whatever program produced the PDF. A layout tool might emit a whole column, then the other column. A converter might emit them line by line across the page. A generator building a table might emit the header row, then every cell down the first column. All of those render identically and read back completely differently.

That single fact explains all three symptoms people run into:

  • InterleavedTwo columns alternating line by line, so every sentence is cut in half by an unrelated one. The stored order crossed the gutter and the copy followed it.
  • No spacesWords fused into each other. Many PDFs contain no space characters at all — the gap between words is produced by moving the drawing cursor, so there is nothing to copy.
  • NothingAn empty selection or an empty clipboard. There are no glyphs on the page at all, only a picture of some — a scan. That one needs OCR, covered further down.

So the fix is not a better copy shortcut. It is a program that looks at where the runs sit on the page and reconstructs the reading order from that geometry, rather than trusting the order the file happens to list them in.

Extract the text in four steps

  1. 1
    Open the extractor. Go to pdfgami.com/pdf-to-text. There is nothing to install, no account, and no cap on how many pages you may extract.
  2. 2
    Drop the PDF. It is parsed in the tab and the file name comes back with its page count. If the PDF is encrypted, damaged, or not really a PDF, you are told that immediately instead of watching a spinner.
  3. 3
    Pick pages and formatting. Leave the Pages field blank for the whole document, or narrow it to 1-5, a single page like 3, or a list like 1,3,5-7. Then decide whether to merge lines into flowing paragraphs, rejoin words split by a hyphen at a line break, and mark page boundaries in the output.
  4. 4
    Extract, then take the text. Click Extract text. Each page appears with its word count, or with a badge if it turned out to be a scan or a blank page. From there, Download .txt saves a file named after your PDF, and Copy all puts the whole thing on the clipboard.

Two columns, and how reading order is rebuilt

Multi-column pages are where naive copying fails most visibly, and they are worth a paragraph of explanation because the fix is not complicated once you see the shape of it. Instead of reading the runs in file order, the extractor turns each one into a box — its position and its size on the page — and then looks for bands of whitespace that run clear across the page. A gutter between two columns is exactly that: a vertical strip with nothing in it, from the top of the text block to the bottom. Cut the page there and you have two blocks. Recurse, and the paragraph gaps inside each block split it further.

The blocks come back in reading order, so a two-column research paper extracts as the left column in full and then the right column in full, rather than the two woven together. A full-width heading above two columns behaves correctly too: the heading crosses the gutter, so no clean vertical cut exists at the top of the page, and the horizontal gap under the heading is found first instead. The heading is peeled off, then the columns underneath are separated.

Inside each block, runs sharing a baseline are grouped into a line, and lines are ordered down the page. That is also where the missing-spaces problem gets solved: the horizontal distance between two neighbouring runs is compared against the height of the text, and a space is inserted when the gap is wide enough to be one. Vertical distances do the equivalent job between lines — a drop noticeably larger than the usual leading reads as a paragraph break rather than an ordinary line break, so the blank lines in the output land where the page shows paragraphs starting.

What changes, on a two-column page
Plain copy-paste
the study examined whether
participants in the control
a total of 240 people were
group reported any change
Geometry-based extraction
the study examined whether
participants in the control
group reported any change

a total of 240 people were

Paragraphs, hyphens and page ranges

Three checkboxes sit beside the page field, and which ones you want depends entirely on where the text is going next.

  • Merge lines into paragraphs. Off by default, which keeps the line breaks the page has. That is what you want if you are quoting a passage, diffing two versions, or feeding the text to something line-oriented. Turn it on and each paragraph becomes one long line, which is what you want before pasting into a document or an email where the text should reflow to the window.
  • Rejoin hyphenated words. Justified print breaks words across lines with a hyphen. Left alone you get experi- and mental on separate lines; with this on they are stitched back into one word. It only fires where the pattern really is a broken word — a lowercase letter before the hyphen and a lowercase letter starting the next line — so genuine hyphenated compounds and dashes at the end of a line are left alone.
  • Mark page boundaries. On by default. It writes a --- Page 7 ---line before each page's text, which is worth keeping whenever you will need to find a passage again in the original.

The page range is the other control worth knowing. A 400-page report where you only need the appendix is faster and far easier to read as pages 380-400, and the field tells you how many pages your input selects before you commit to anything. Ask for a range the document does not have and it says so rather than quietly giving you something else.

When copying gives you nothing: scanned PDFs

If selecting text in your viewer does nothing at all — no highlight, no cursor, nothing on the clipboard — the PDF is almost certainly a scan. Someone put paper through a scanner or photographed it with a phone, and each page of the file is a single image. It looks like a document to you and it is a picture to software. There is no text to copy because there is no text in the file.

Most extractors handle this badly: they return an empty file, or a file with the page markers and nothing between them, and leave you to work out whether the tool is broken. This one checks. When a page comes back with essentially no characters, it asks whether that page paints any images. If it does, the page is reported as a scan; if it does not, it is reported as genuinely blank. You get a count at the top of the results — 3 scanned pages — a badge on each affected page saying Scan — no text layer, and a bracketed note in the same position in the downloaded .txt so the gap is visible rather than invisible. If no page in your selection had any text at all, the tool says plainly that the PDF is a scan, that reading it needs OCR, and that PDFGami does not do OCR.

That limit is deliberate rather than an oversight. A usable OCR engine is a large model to ship into a web page, and a small one produces output that looks plausible and is quietly wrong — exactly the failure mode you cannot afford on a contract or a prescription. Saying “these four pages are images, here is what to do” is more useful than a paragraph of confident nonsense.

Honest OCR options, and what each one costs you

OCR — optical character recognition — is the step that turns pictures of letters back into letters. If your PDF is a scan, this is the part you need, and it has to come from somewhere other than this site. Three routes cover almost every case:

  • Adobe Acrobat Pro. Its Scan & OCR tool recognises the text and writes it back into the PDF as a real text layer, so afterwards the file behaves like any other PDF and ordinary copying works. The recognition runs on your machine. It is the most reliable option and it is a paid subscription.
  • macOS Preview, using Live Text. On a reasonably recent Mac, open the scan in Preview and try selecting the text anyway — the system recognises text in images on the device, and selection and copy often simply work. Free, already installed, nothing leaves the Mac. It is per-selection rather than a whole-document conversion, which makes it excellent for a page and tedious for a hundred.
  • Google Drive. Upload the PDF, then open it with Google Docs; Drive runs OCR during the conversion and hands you an editable document. It is free and it copes well with imperfect scans. The trade-off is explicit and you should weigh it rather than skip it: the file is uploaded, and a copy of it then lives in Google's systems under their terms and your account's retention settings. Fine for a recipe or a flyer. Think harder about a signed contract, a payslip, a medical record or anything covered by a confidentiality obligation.

If the OCR tool you choose wants images rather than a PDF, PDFGami's PDF to JPG converter will render the pages out as pictures in your browser first, which at least keeps that half of the job local. And once a scan has been through OCR and has a text layer, bring it back to the text extractor — the reading-order reconstruction is just as useful on a recognised document as on a born-digital one.

Before you go looking for OCR at all, check whether you actually need it. A great many PDFs that look like scans are not: if you can select a word in your viewer, even clumsily, there is a text layer and extraction will work. The badges in the results tell you the answer for every page in one pass.

What plain text cannot carry

The output here is a .txt file, and that is the whole point of it: characters, spaces and line breaks, nothing else. No fonts, no bold or italic, no heading levels, no colours, no images, no links. That is exactly right when the text is going into a search index, a script, a translation tool, a word counter or a diff — and it is the wrong tool when the layout is the thing you are trying to keep.

Tables deserve a specific warning. A table in a PDF is not a table; it is a set of separately positioned cells that happen to line up, sometimes with lines drawn around them. Flattening that into rows of text loses the grid. You will usually get every cell's contents in a reasonable order, but do not expect columns you can paste into a spreadsheet, and check the numbers if they matter. No browser-only plain-text extractor will do better honestly.

When you want the text back in something editable with its structure roughly intact, use PDF to DOCX instead, and read what it says about how faithful the conversion can be. Two other habits also help: the extractor handles one PDF at a time, so work through a set one file at a time rather than looking for a batch mode that would hide which document a passage came from, and remember that a very long document lives in your tab's memory while it is being parsed — a 900-page scan on a phone will run out of room sooner than the same file on a laptop.

Why none of this needs an upload

Everything above happens as JavaScript in the tab you already have open. pdf.js, the PDF engine Firefox itself uses to display PDFs, parses the file and hands back the positioned text runs; the reconstruction, the formatting options and the .txt you download are all built from those runs locally. There is no upload step, so there is no queue, no file size limit set by someone else's server, and no copy of your document sitting on a disk you do not control.

That matters more for text extraction than for almost anything else, because of what people extract text from. The documents where copy-paste is most infuriating — contracts, court filings, research under embargo, medical letters, payslips — are precisely the documents you should not be handing to an anonymous conversion site in exchange for a tidier clipboard.

Do not take that on trust from us, either. Open your browser's developer tools, switch to the Network tab, and run an extraction: if a tool uploads, you will see a request roughly the size of your file. Here the tab stays quiet: the request that would carry your document never happens, and that is the part of the claim you can verify rather than trust. The same test works on every site that claims local processing — are online PDF tools safe? goes through it in more detail, along with what the usual privacy policies actually permit.

Frequently asked questions

How do I copy text from a PDF?

If the PDF has a text layer, select the passage in any viewer and copy it — that works for a sentence or two. For a whole page, a chapter or a document, selection gets unreliable and you are better off extracting: open PDFGami's PDF to Text tool, drop the file, optionally give a page range, and click Extract text. You get the text on screen page by page, with a Download .txt button and a Copy all button. The PDF is parsed by pdf.js inside your own browser, so nothing is uploaded.

Why does text copied from a PDF come out scrambled?

Because a PDF does not store sentences. It stores thousands of small runs of glyphs, each with a position on the page, and the order they were written in is whatever the program that made the file happened to use. Copying follows that stored order rather than the visual layout, so on a two-column page you get a line of the left column, then a line of the right, alternating all the way down. Extraction that rebuilds the order from the geometry of those runs — which is what this tool does — reads the columns one after the other instead.

Why do the words run together with no spaces when I paste?

Because many PDFs contain no space characters at all. The gap between two words is drawn by moving the cursor, not by storing a space, so a naive copy concatenates the runs and you get "thequickbrownfox". The extractor measures the horizontal distance between neighbouring runs and inserts a space when the gap is wide enough relative to the text height, which puts the spaces back where the page shows them.

How do I copy text from a scanned PDF?

You cannot copy it, because there is no text in the file — the pages are photographs of a document. Reading them back needs OCR, which recognises letter shapes inside an image. PDFGami does not do OCR, and says so rather than handing you an empty file: it detects pages that paint images but carry no text layer, labels them as scans, and tells you which page numbers they are. For the OCR itself you need Acrobat Pro, macOS Preview's Live Text, Google Drive, or another dedicated OCR tool.

Can I extract text from only some pages?

Yes. The Pages field takes a range like 1-5, a single page like 3, or a mixed list like 1,3,5-7. Leave it blank and every page is extracted. The field tells you how many pages your input selects before you run anything, and rejects a range that falls outside the document rather than silently clamping it.

Does extracting text keep the bold, the headings and the tables?

No, and it does not pretend to. The output is plain .txt: no fonts, no bold or italic, no heading levels, no colours. Tables are the honest weak point — a table is a grid of separately positioned cells, and flattening a grid into lines of text loses the grid. You will usually get the cell contents in a sensible left-to-right, top-to-bottom order, but not aligned columns you can paste into a spreadsheet. If you need the layout to survive, convert to a document format instead of extracting plain text.

Is my PDF uploaded when I extract text online?

On most sites, yes. The usual design is an upload form, a server-side extractor, and a download link, which means a copy of your file sits on someone else's disk under a retention policy you did not read. PDFGami parses the PDF with pdf.js in your own tab, in JavaScript, and never sends it anywhere. You can check that yourself: open developer tools, switch to the Network tab, and extract. Nothing carries the file — the request that would have to exist simply never happens.

Can I extract several PDFs at once?

No — the extractor works on one PDF at a time, and the page range, the formatting options and the per-page results all belong to that one document. Run them one after another; each extraction is a few seconds of local work with nothing queued behind anyone else.

Continue reading

Get the text out properly

Drop the PDF, choose your pages, and take the result as a .txt or straight to the clipboard — columns in order, spaces where they belong, and scans flagged rather than silently skipped.

Open the PDF Text Extractor