errantanomie commited on
Commit
ba39ca8
·
verified ·
1 Parent(s): b035e93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -67,7 +67,11 @@ def process_pdf(file):
67
  st.error(f"Error on page {i + 1}: {e}")
68
  finally:
69
  os.remove(temp_pdf_path)
70
- return text
 
 
 
 
71
 
72
 
73
  # Function to generate thumbnail from PDF
@@ -107,7 +111,7 @@ def generate_unique_filename(original_filename, suffix, file_type):
107
  now = datetime.now()
108
  timestamp = now.strftime("%Y%m%d_%H%M%S")
109
  name, ext = os.path.splitext(original_filename)
110
- return f"{name}_{timestamp}{suffix}{ext or file_type}"
111
 
112
  def rotate_pdf(pdf_file, rotation_angle):
113
  """Rotates all pages of a PDF by a specified angle."""
@@ -190,7 +194,6 @@ elif selection == "PDF Transcriber":
190
  else:
191
  st.error("Could not process the PDF, please try again")
192
 
193
-
194
  # PDF Rotator Tool
195
  elif selection == "PDF Rotator":
196
  st.title("PDF Rotator")
 
67
  st.error(f"Error on page {i + 1}: {e}")
68
  finally:
69
  os.remove(temp_pdf_path)
70
+
71
+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False) as temp_txt:
72
+ temp_txt.write(text.encode("utf-8"))
73
+ temp_txt_path = temp_txt.name
74
+ return temp_txt_path
75
 
76
 
77
  # Function to generate thumbnail from PDF
 
111
  now = datetime.now()
112
  timestamp = now.strftime("%Y%m%d_%H%M%S")
113
  name, ext = os.path.splitext(original_filename)
114
+ return f"{name}_{timestamp}{suffix}{file_type}"
115
 
116
  def rotate_pdf(pdf_file, rotation_angle):
117
  """Rotates all pages of a PDF by a specified angle."""
 
194
  else:
195
  st.error("Could not process the PDF, please try again")
196
 
 
197
  # PDF Rotator Tool
198
  elif selection == "PDF Rotator":
199
  st.title("PDF Rotator")