30 lines
745 B
Python
30 lines
745 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from weasyprint import HTML
|
|
|
|
|
|
class OrionReportService:
|
|
chapters = [
|
|
"Deckblatt",
|
|
"Inhaltsverzeichnis",
|
|
"Zusammenfassung",
|
|
"Gerät",
|
|
"Kunde",
|
|
"Normen",
|
|
"Prüfmittel",
|
|
"Programme",
|
|
"Beladung",
|
|
"Messungen",
|
|
"Diagramme",
|
|
"Empfehlungen",
|
|
"Anlagen",
|
|
]
|
|
|
|
def render_pdf(self, title: str, output_path: Path) -> Path:
|
|
chapter_markup = "".join(f"<section><h2>{chapter}</h2></section>" for chapter in self.chapters)
|
|
html = f"<html><body><h1>{title}</h1>{chapter_markup}</body></html>"
|
|
HTML(string=html).write_pdf(output_path)
|
|
return output_path
|
|
|