Dave67350 commited on
Commit
d94a596
·
verified ·
1 Parent(s): b545b3f

Update tools/ai_act_generator.py

Browse files
Files changed (1) hide show
  1. tools/ai_act_generator.py +5 -2
tools/ai_act_generator.py CHANGED
@@ -18,7 +18,10 @@ from fpdf import FPDF
18
  from langdetect import detect
19
 
20
  # === PDF Export Function with Language Option ===
21
- def export_text_to_pdf(text, output_path="ai_act_register.pdf", language="fr"):
 
 
 
22
  pdf = FPDF()
23
  pdf.add_page()
24
  pdf.set_auto_page_break(auto=True, margin=15)
@@ -122,7 +125,7 @@ Generated by AI Act Assistant.
122
 
123
  pdf_path = export_text_to_pdf(filled_template, language=detected_lang)
124
  return f"""{flag} Language detected: {detected_lang.upper()}
125
- ✅ All answers received. [Download your AI Act compliance PDF here]({pdf_path})""", {"done": True, "pdf": pdf_path}, pdf_path
126
 
127
  # === UI for Step-by-Step Form ===
128
  def launch_step_by_step_ui():
 
18
  from langdetect import detect
19
 
20
  # === PDF Export Function with Language Option ===
21
+ def export_text_to_pdf(text, output_path=None, language="fr"):
22
+ if output_path is None:
23
+ timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
24
+ output_path = f"ai_act_register_{timestamp}.pdf"
25
  pdf = FPDF()
26
  pdf.add_page()
27
  pdf.set_auto_page_break(auto=True, margin=15)
 
125
 
126
  pdf_path = export_text_to_pdf(filled_template, language=detected_lang)
127
  return f"""{flag} Language detected: {detected_lang.upper()}
128
+ ✅ All answers received. Your PDF is ready for download below.""", {"done": True, "pdf": pdf_path}, pdf_path
129
 
130
  # === UI for Step-by-Step Form ===
131
  def launch_step_by_step_ui():