diff --git a/list-generator/backend/app/services/pdf_generator.py b/list-generator/backend/app/services/pdf_generator.py index b4ab40935..80a51baff 100644 --- a/list-generator/backend/app/services/pdf_generator.py +++ b/list-generator/backend/app/services/pdf_generator.py @@ -3,6 +3,16 @@ import os from jinja2 import Environment, FileSystemLoader from weasyprint import HTML import datetime +import base64 + +def get_logo_base64(): + logo_path = os.path.join(os.path.dirname(__file__), "..", "..", "assets", "logo.png") + try: + with open(logo_path, "rb") as image_file: + return base64.b64encode(image_file.read()).decode('utf-8') + except FileNotFoundError: + print(f"Warning: Logo file not found at {logo_path}") + return None def generate_school_pdf(institution: str, date_info: str, list_type: str, students_csv_path: str, families_csv_path: str = None, output_dir: str = "/tmp") -> str: df = None @@ -43,7 +53,16 @@ def generate_school_pdf(institution: str, date_info: str, list_type: str, studen env = Environment(loader=FileSystemLoader(template_dir)) template = env.get_template("school_list.html") current_time = datetime.datetime.now().strftime("%d.%m.%Y %H:%M Uhr") - html_out = template.render(institution=institution, date_info=date_info, class_counts=class_counts, total_students=total_students, class_data=class_data, current_time=current_time) + logo_base64 = get_logo_base64() + html_out = template.render( + institution=institution, + date_info=date_info, + class_counts=class_counts, + total_students=total_students, + class_data=class_data, + current_time=current_time, + logo_base64=logo_base64 + ) clean_inst = institution.replace(" ", "_").replace("/", "-") time_str = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M") output_filename = f"Listen_{clean_inst}_{list_type}_{time_str}.pdf" diff --git a/list-generator/backend/app/templates/school_list.html b/list-generator/backend/app/templates/school_list.html index 53b35a57a..4718d566f 100644 --- a/list-generator/backend/app/templates/school_list.html +++ b/list-generator/backend/app/templates/school_list.html @@ -20,7 +20,15 @@ .footer-left { text-align: left; } .footer-right { text-align: right; white-space: pre-wrap; } -
{{ institution }}
{{ date_info }}
+
+
+
{{ institution }}
+
{{ date_info }}
+
+
+ Logo +
+

Übersicht der Anmeldungen:

{% for count in class_counts %} @@ -28,7 +36,15 @@
Klasse {{ count.name }}{{ count.count }} Anmeldungen
Gesamt: {{ total_students }} Anmeldungen
{% for class_info in class_data %}
-
{{ institution }}
{{ date_info }}
+
+
+
{{ institution }}
+
{{ date_info }}
+
+
+ Logo +
+
{% for student in class_info.students %} diff --git a/list-generator/backend/assets/logo.png b/list-generator/backend/assets/logo.png new file mode 100644 index 000000000..d19467ddd Binary files /dev/null and b/list-generator/backend/assets/logo.png differ
NachnameVornameKlasse
{{ student.Nachname }}{{ student.Vorname }}{{ student.Klasse }}