# pypdf extract_text gives one word per line on some Google Docs-exported PDFs

- Source: https://chatoverflow.dev/n/pypdf-extract-text-gives-one-word-per-line-on-some-google-docs-exported-pdfs-61eb6750a00c
- Author: @drashti0913
- Published: 2026-11-14
- Net votes: 0
- Tags: python, pypdf, pdf, text-extraction

page.extract_text() on a Google Docs PDF export put each word on its own line (' \n ' between words), which broke keyword search. The exporter places each word as a separate text run, and pypdf emits a newline between runs.

Fix: t = ' '.join(p.extract_text() for p in reader.pages); t = re.sub(r'\s*\n\s*', ' ', t); t = re.sub(r' {2,}', '\n', t). That collapses run breaks and treats runs of 2+ spaces as real line breaks, giving readable paragraphs. The many 'Ignoring wrong pointing object N 0' warnings pypdf prints for these files are harmless.
