File size: 539 Bytes
ab81fa8 |
1 2 3 4 5 6 7 8 9 10 11 12 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
def generate_pdf(report_data, filename="report.pdf"):
doc = SimpleDocTemplate(filename)
styles = getSampleStyleSheet()
flow = [Paragraph("Clinical Report", styles["Title"]), Spacer(1,12)]
for section, content in report_data.items():
flow += [Paragraph(f"<b>{section}</b>", styles["Heading2"]), Paragraph(str(content), styles["BodyText"]), Spacer(1,12)]
doc.build(flow)
return filename
|