PDF extraction returning empty text — PyPDF2 issue
Started by Michael Torres · 3 months ago
J
James Wilson
4 months ago
Scanned PDFs are images, not text. PyPDF2 can only extract text layers. You need OCR — try pytesseract with Pillow:\n\n```python\nfrom PIL import Image\nimport pytesseract\n\ntext = pytesseract.image_to_string(Image.open("scanned_page.png"))\n```
M
Michael Torres
4 months ago
I'm using PyPDF2 to extract text from scanned PDFs but getting empty strings. The file definitely has text visible when opened in a reader.
L
Lisa Nakamura
3 months ago
If the PDF has mixed content (some pages scanned, some digital), check each page: if extract_text() returns empty, fall back to OCR for that page.
Sign in to reply to this topic.