Update app.py
Browse files
app.py
CHANGED
|
@@ -117,8 +117,11 @@ def extract_text_from_pdf(pdf_path):
|
|
| 117 |
text += page_text + "\n"
|
| 118 |
if text.strip():
|
| 119 |
return text
|
| 120 |
-
except:
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
# Fallback: OCR
|
| 124 |
print("No selectable text found. Running OCR...")
|
|
|
|
| 117 |
text += page_text + "\n"
|
| 118 |
if text.strip():
|
| 119 |
return text
|
| 120 |
+
except Exception as e:
|
| 121 |
+
print("pypdf failed:", e)
|
| 122 |
+
|
| 123 |
+
# If no text, give a clear message (no OCR attempt)
|
| 124 |
+
return "❌ This PDF is scanned or does not contain selectable text. Please upload a text‑based PDF."
|
| 125 |
|
| 126 |
# Fallback: OCR
|
| 127 |
print("No selectable text found. Running OCR...")
|