from typing import List from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas def write_pdf_report(pdf_path: str, title: str, lines: List[str]) -> str: """ Simple, robust PDF export for stakeholders. We render plain text lines (already human-friendly via report.md). """ c = canvas.Canvas(pdf_path, pagesize=letter) w, h = letter # noqa: F841 x = 50 y = h - 60 c.setFont("Helvetica-Bold", 16) c.drawString(x, y, title[:90]) y -= 30 c.setFont("Helvetica", 11) for line in lines: # page break if y < 60: c.showPage() y = h - 60 c.setFont("Helvetica", 11) # hard wrap-ish s = line.replace("\t", " ") # keep simple: clip long lines c.drawString(x, y, s[:120]) y -= 14 c.save() return pdf_path