Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,12 @@ from pdf2image import convert_from_path
|
|
| 6 |
|
| 7 |
def pdf_to_text(pdf_file):
|
| 8 |
# Open the PDF file
|
| 9 |
-
pdf = PyPDF2.
|
| 10 |
|
| 11 |
# Extract the text from each page
|
| 12 |
text = ''
|
| 13 |
-
for page in
|
| 14 |
-
|
| 15 |
-
text += page_obj.extractText()
|
| 16 |
|
| 17 |
# If the text is empty, use OCR to extract the text
|
| 18 |
if not text:
|
|
|
|
| 6 |
|
| 7 |
def pdf_to_text(pdf_file):
|
| 8 |
# Open the PDF file
|
| 9 |
+
pdf = PyPDF2.PdfReader(pdf_file)
|
| 10 |
|
| 11 |
# Extract the text from each page
|
| 12 |
text = ''
|
| 13 |
+
for page in pdf.pages:
|
| 14 |
+
text += page.extract_text()
|
|
|
|
| 15 |
|
| 16 |
# If the text is empty, use OCR to extract the text
|
| 17 |
if not text:
|