Spaces:
Sleeping
Sleeping
Update tools/ai_act_generator.py
Browse files
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=
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 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():
|