Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,14 +32,17 @@ def main():
|
|
| 32 |
|
| 33 |
if pdf_file is not None:
|
| 34 |
text = pdf_to_text(pdf_file)
|
| 35 |
-
st.write("Extracted Text:")
|
| 36 |
-
st.code(text)
|
| 37 |
-
|
| 38 |
-
# Save the text to a .txt file
|
| 39 |
txt_file = pdf_file.name.replace('.pdf', '.txt')
|
| 40 |
with open(txt_file, 'w') as f:
|
| 41 |
f.write(text)
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
| 45 |
main()
|
|
|
|
| 32 |
|
| 33 |
if pdf_file is not None:
|
| 34 |
text = pdf_to_text(pdf_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
txt_file = pdf_file.name.replace('.pdf', '.txt')
|
| 36 |
with open(txt_file, 'w') as f:
|
| 37 |
f.write(text)
|
| 38 |
+
|
| 39 |
+
with open(txt_file, "rb") as file:
|
| 40 |
+
btn = st.download_button(
|
| 41 |
+
label="Download Extracted Text",
|
| 42 |
+
data=file,
|
| 43 |
+
file_name=txt_file,
|
| 44 |
+
mime="text/plain"
|
| 45 |
+
)
|
| 46 |
|
| 47 |
if __name__ == "__main__":
|
| 48 |
main()
|