File size: 875 Bytes
0b23bcd 318a8fc 0b23bcd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
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 |