Spaces:
Sleeping
Sleeping
Update reports/export_pdf.py
Browse files- reports/export_pdf.py +8 -7
reports/export_pdf.py
CHANGED
|
@@ -40,7 +40,7 @@ def create_ei_heatmap(data):
|
|
| 40 |
plt.close(fig)
|
| 41 |
return tmp.name
|
| 42 |
|
| 43 |
-
# 3.
|
| 44 |
def generate_report():
|
| 45 |
st.subheader("📄 Export Your Weekly Report")
|
| 46 |
|
|
@@ -66,6 +66,7 @@ def generate_report():
|
|
| 66 |
pdf.add_page()
|
| 67 |
pdf.set_auto_page_break(auto=True, margin=15)
|
| 68 |
|
|
|
|
| 69 |
pdf.set_font("Arial", 'B', 14)
|
| 70 |
pdf.cell(0, 10, f"MindMentor Report - {name}", ln=True, align='C')
|
| 71 |
pdf.set_font("Arial", '', 11)
|
|
@@ -114,7 +115,7 @@ def generate_report():
|
|
| 114 |
pdf.image(heatmap_path, w=100)
|
| 115 |
os.unlink(heatmap_path)
|
| 116 |
|
| 117 |
-
#
|
| 118 |
pdf.set_font("Arial", 'B', 12)
|
| 119 |
pdf.cell(0, 10, "Overall Summary", ln=True)
|
| 120 |
pdf.set_font("Arial", '', 11)
|
|
@@ -124,16 +125,16 @@ def generate_report():
|
|
| 124 |
"Keep up your cognitive training and continue practicing daily EI drills for balanced growth."
|
| 125 |
)
|
| 126 |
|
| 127 |
-
#
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
pdf_data = pdf_buffer.getvalue()
|
| 131 |
|
| 132 |
st.download_button(
|
| 133 |
label="📄 Download Your MindMentor PDF Report",
|
| 134 |
-
data=
|
| 135 |
file_name=f"{name}_MindMentor_Report.pdf",
|
| 136 |
mime="application/pdf"
|
| 137 |
)
|
| 138 |
|
| 139 |
|
|
|
|
|
|
| 40 |
plt.close(fig)
|
| 41 |
return tmp.name
|
| 42 |
|
| 43 |
+
# 3. Main report function
|
| 44 |
def generate_report():
|
| 45 |
st.subheader("📄 Export Your Weekly Report")
|
| 46 |
|
|
|
|
| 66 |
pdf.add_page()
|
| 67 |
pdf.set_auto_page_break(auto=True, margin=15)
|
| 68 |
|
| 69 |
+
# Title and intro
|
| 70 |
pdf.set_font("Arial", 'B', 14)
|
| 71 |
pdf.cell(0, 10, f"MindMentor Report - {name}", ln=True, align='C')
|
| 72 |
pdf.set_font("Arial", '', 11)
|
|
|
|
| 115 |
pdf.image(heatmap_path, w=100)
|
| 116 |
os.unlink(heatmap_path)
|
| 117 |
|
| 118 |
+
# Final Summary
|
| 119 |
pdf.set_font("Arial", 'B', 12)
|
| 120 |
pdf.cell(0, 10, "Overall Summary", ln=True)
|
| 121 |
pdf.set_font("Arial", '', 11)
|
|
|
|
| 125 |
"Keep up your cognitive training and continue practicing daily EI drills for balanced growth."
|
| 126 |
)
|
| 127 |
|
| 128 |
+
# Convert to BytesIO for download
|
| 129 |
+
pdf_output = pdf.output(dest='S').encode('latin1')
|
| 130 |
+
pdf_buffer = io.BytesIO(pdf_output)
|
|
|
|
| 131 |
|
| 132 |
st.download_button(
|
| 133 |
label="📄 Download Your MindMentor PDF Report",
|
| 134 |
+
data=pdf_buffer,
|
| 135 |
file_name=f"{name}_MindMentor_Report.pdf",
|
| 136 |
mime="application/pdf"
|
| 137 |
)
|
| 138 |
|
| 139 |
|
| 140 |
+
|