Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,7 +87,9 @@ def extract_pdf_text(file_data):
|
|
| 87 |
try:
|
| 88 |
pdf_document = fitz.open(stream=file_data, filetype="pdf")
|
| 89 |
text = "\n".join([page.get_text("text") for page in pdf_document])
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
except Exception as e:
|
| 92 |
logger.error(f"PDF Extraction Error: {e}")
|
| 93 |
return None
|
|
|
|
| 87 |
try:
|
| 88 |
pdf_document = fitz.open(stream=file_data, filetype="pdf")
|
| 89 |
text = "\n".join([page.get_text("text") for page in pdf_document])
|
| 90 |
+
pdf_document.close() # Explicitly close the PDF
|
| 91 |
+
return text if text.strip() else "" # Handle empty PDFs gracefully
|
| 92 |
+
|
| 93 |
except Exception as e:
|
| 94 |
logger.error(f"PDF Extraction Error: {e}")
|
| 95 |
return None
|