Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,11 +37,17 @@ def text_extraction(element):
|
|
| 37 |
return (line_text, format_per_line)
|
| 38 |
|
| 39 |
def read_pdf(pdf_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# create a PDF file object
|
| 41 |
-
pdfFileObj = open(pdf_path, 'rb')
|
| 42 |
# create a PDF reader object
|
| 43 |
-
pdfReaded = PyPDF2.PdfReader(pdfFileObj)
|
| 44 |
-
#pdfReaded = PdfReader(pdfFileObj)
|
| 45 |
# Create the dictionary to extract text from each image
|
| 46 |
text_per_page = {}
|
| 47 |
# We extract the pages from the PDF
|
|
|
|
| 37 |
return (line_text, format_per_line)
|
| 38 |
|
| 39 |
def read_pdf(pdf_path):
|
| 40 |
+
|
| 41 |
+
# Use pdf_path.name to get the file name from the gr.File object
|
| 42 |
+
with open(pdf_path.name, 'rb') as pdfFileObj:
|
| 43 |
+
pdfReaded = PyPDF2.PdfReader(pdfFileObj)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
# create a PDF file object
|
| 48 |
+
#pdfFileObj = open(pdf_path, 'rb')
|
| 49 |
# create a PDF reader object
|
| 50 |
+
#pdfReaded = PyPDF2.PdfReader(pdfFileObj)
|
|
|
|
| 51 |
# Create the dictionary to extract text from each image
|
| 52 |
text_per_page = {}
|
| 53 |
# We extract the pages from the PDF
|