Spaces:
Sleeping
Sleeping
Update convert.py
Browse files- convert.py +0 -8
convert.py
CHANGED
|
@@ -7,7 +7,6 @@ def ExtractPDFText(pdf):
|
|
| 7 |
pdf_bytes = pdf.read()
|
| 8 |
|
| 9 |
try:
|
| 10 |
-
# Open the PDF using fitz
|
| 11 |
pdf_document = fitz.open("dummy.pdf", pdf_bytes)
|
| 12 |
|
| 13 |
# Iterate through pages and extract text
|
|
@@ -20,16 +19,9 @@ def ExtractPDFText(pdf):
|
|
| 20 |
st.error(f"Error extracting text from PDF: {e}")
|
| 21 |
|
| 22 |
finally:
|
| 23 |
-
# Close the PDF document
|
| 24 |
if "pdf_document" in locals():
|
| 25 |
pdf_document.close()
|
| 26 |
|
| 27 |
return content
|
| 28 |
|
| 29 |
-
# Example usage in Streamlit app
|
| 30 |
-
pdf = st.file_uploader("Upload a PDF file", type=["pdf"])
|
| 31 |
|
| 32 |
-
if pdf:
|
| 33 |
-
text_content = ExtractPDFText(pdf)
|
| 34 |
-
st.write("PDF Content:")
|
| 35 |
-
# st.write(text_content)
|
|
|
|
| 7 |
pdf_bytes = pdf.read()
|
| 8 |
|
| 9 |
try:
|
|
|
|
| 10 |
pdf_document = fitz.open("dummy.pdf", pdf_bytes)
|
| 11 |
|
| 12 |
# Iterate through pages and extract text
|
|
|
|
| 19 |
st.error(f"Error extracting text from PDF: {e}")
|
| 20 |
|
| 21 |
finally:
|
|
|
|
| 22 |
if "pdf_document" in locals():
|
| 23 |
pdf_document.close()
|
| 24 |
|
| 25 |
return content
|
| 26 |
|
|
|
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|