Copying from PDF and Word without losing text

Topic illustration for the article: Copying from PDF and Word without losing text
Practical illustration for this guide

After text is copied from PDF or Word, a word may split, paragraphs may change order, or exact search may stop finding a visible phrase. These symptoms look similar but need different repairs. An unwanted invisible character can be removed precisely; a cleaner cannot reconstruct lost column order, repair OCR, or guess which letter the source image contained.

Try the example in the cleaner

Classify the failure before editing

Compare one short extract with the source. If the letters are correct but the cursor makes an extra stop or exact comparison fails, inspect code points. A substituted letter is more likely an OCR error. Sentences appearing out of order may indicate a PDF reading-order problem. W3C explains that visual and logical order agree only when the document is structured correctly.

  • Break inside a word: distinguish U+00AD SOFT HYPHEN, U+002D HYPHEN-MINUS, and a newline.
  • Unexpected space: distinguish U+0020 from U+00A0 NBSP and U+202F.
  • Reordered lines: export again or choose extraction that understands PDF structure.
  • Wrong letters: rerun OCR on the source image.

A reproducible soft-hyphen example

inter[U+00AD]national contains a discretionary line-break hint rather than a visible hyphen. Software may display a hyphen when the word wraps and hide it on a wide line. After confirming U+00AD, remove that character to obtain international. Unicode describes soft hyphen as part of line-breaking behavior, so replacing every U+00AD with an ordinary hyphen changes the data.

A different extract may contain inter-, a newline, then national. Joining every pair is unsafe: the hyphen may belong to a compound and the newline may separate a list item, caption, or table row. Apply a joining rule only to a known document type and verify several examples.

A safer workflow

  1. Keep the original PDF or DOCX and work on a copy of the extracted text.
  2. Highlight one failing paragraph and record the code points found.
  3. Change one character class, then retest in the application where the failure occurred.
  4. Process prose, tables, headers, footers, and captions separately.
  5. After a batch change, compare paragraph boundaries, links, numbers, and table row counts.

For confidential documents, use local processing and do not paste material into unrelated forms without permission. txtclean.site processes cleaning in the browser, but the browser can retain input locally for recovery; clear site data after using a shared computer.

Acceptance checks

Sample the start and end of the document, a page boundary, a number with a unit, a link, and a table. Exact search should find the repaired phrase while punctuation and meaning still match the source. In multilingual text, inspect combining marks, bidirectional controls, and emoji sequences: ZWJ and ZWNJ may be meaningful.

When to return to the source

If selection follows an unexpected order, a table becomes unrelated lines, or OCR confuses similar glyphs, repeat the export from Word or use a PDF extractor that preserves structure. The cleaner sees only the resulting string. It has no page coordinates and cannot recreate layout information that was never included.

Open the cleaner

Sources and related guides