zmbfeng commited on
Commit
25c9941
1 Parent(s): bfc7f18

download txt file working

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import utils
4
  import numpy as np
5
  import cv2
6
  import os
 
7
  import shutil
8
 
9
  import time
@@ -136,7 +137,14 @@ if 'page_count' in st.session_state:
136
  #st.session_state['video_generated'] = True
137
  st.rerun()
138
  if 'extracted_text' in st.session_state:
 
 
 
 
 
 
139
  st.write(st.session_state.extracted_text)
 
140
  # for index, gray_pdf_image_np in enumerate(st.session_state.gray_image_np_list[0:5], start=0):
141
  # print("index="+str(index))
142
  #
 
4
  import numpy as np
5
  import cv2
6
  import os
7
+ import io
8
  import shutil
9
 
10
  import time
 
137
  #st.session_state['video_generated'] = True
138
  st.rerun()
139
  if 'extracted_text' in st.session_state:
140
+ string_buffer = io.StringIO(st.session_state.extracted_text)
141
+ txt_file_path=uploaded_locked_pdf_file.name.replace(".pdf", ".txt")
142
+ st.download_button(label="Download Extraction txt File",
143
+ data=string_buffer.getvalue(),
144
+ file_name=txt_file_path,
145
+ mime="text/plain")
146
  st.write(st.session_state.extracted_text)
147
+
148
  # for index, gray_pdf_image_np in enumerate(st.session_state.gray_image_np_list[0:5], start=0):
149
  # print("index="+str(index))
150
  #