Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,3 +103,80 @@ if uploaded_file is not None:
|
|
| 103 |
b64 = base64.b64encode(report_text.encode()).decode()
|
| 104 |
href = f'<a href="data:file/txt;base64,{b64}" download="cv_analysis_report.txt">Download Full CV Analysis Report</a>'
|
| 105 |
st.markdown(href, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
b64 = base64.b64encode(report_text.encode()).decode()
|
| 104 |
href = f'<a href="data:file/txt;base64,{b64}" download="cv_analysis_report.txt">Download Full CV Analysis Report</a>'
|
| 105 |
st.markdown(href, unsafe_allow_html=True)
|
| 106 |
+
|
| 107 |
+
from PIL import Image
|
| 108 |
+
|
| 109 |
+
def generate_pdf_report():
|
| 110 |
+
pdf = FPDF()
|
| 111 |
+
pdf.add_page()
|
| 112 |
+
pdf.set_font("Arial", size=12)
|
| 113 |
+
|
| 114 |
+
def write_line(text):
|
| 115 |
+
pdf.multi_cell(0, 10, text)
|
| 116 |
+
|
| 117 |
+
write_line(f"CV Analysis Report - {datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}\n")
|
| 118 |
+
write_line(f"CV Type: {cv_type}")
|
| 119 |
+
write_line(f"Education Level: {education_level}")
|
| 120 |
+
write_line(f"Overall CV Score: {score} / 100\n")
|
| 121 |
+
|
| 122 |
+
write_line("Score Breakdown:")
|
| 123 |
+
for k, v in score_breakdown.items():
|
| 124 |
+
write_line(f"- {k}: {v}")
|
| 125 |
+
write_line("")
|
| 126 |
+
|
| 127 |
+
write_line("Certification Suggestions:")
|
| 128 |
+
if isinstance(certs, list):
|
| 129 |
+
for c in certs:
|
| 130 |
+
write_line(f"- {c}")
|
| 131 |
+
else:
|
| 132 |
+
write_line(str(certs))
|
| 133 |
+
write_line("")
|
| 134 |
+
|
| 135 |
+
write_line("Higher Education Suggestions:")
|
| 136 |
+
if isinstance(edu, list):
|
| 137 |
+
for e in edu:
|
| 138 |
+
write_line(f"- {e}")
|
| 139 |
+
else:
|
| 140 |
+
write_line(str(edu))
|
| 141 |
+
write_line("")
|
| 142 |
+
|
| 143 |
+
write_line("Visa Recommendations:")
|
| 144 |
+
if isinstance(visa, list):
|
| 145 |
+
for v in visa:
|
| 146 |
+
write_line(f"- {v}")
|
| 147 |
+
else:
|
| 148 |
+
write_line(str(visa))
|
| 149 |
+
write_line("")
|
| 150 |
+
|
| 151 |
+
write_line("Career Advice:")
|
| 152 |
+
write_line(str(advice))
|
| 153 |
+
write_line("")
|
| 154 |
+
|
| 155 |
+
write_line("Job Listings:")
|
| 156 |
+
if isinstance(jobs, list):
|
| 157 |
+
for job in jobs:
|
| 158 |
+
write_line(f"- {job}")
|
| 159 |
+
else:
|
| 160 |
+
write_line(str(jobs))
|
| 161 |
+
|
| 162 |
+
# --- Add Roadmap Chart Image ---
|
| 163 |
+
pdf.add_page()
|
| 164 |
+
pdf.set_font("Arial", "B", 14)
|
| 165 |
+
pdf.cell(0, 10, "Career Roadmap Timeline", ln=True)
|
| 166 |
+
|
| 167 |
+
img_buf = io.BytesIO()
|
| 168 |
+
fig.savefig(img_buf, format="PNG", bbox_inches="tight")
|
| 169 |
+
img_buf.seek(0)
|
| 170 |
+
|
| 171 |
+
# Convert to PIL Image to get correct dimensions for PDF scaling
|
| 172 |
+
image = Image.open(img_buf)
|
| 173 |
+
width, height = image.size
|
| 174 |
+
aspect = height / width
|
| 175 |
+
pdf_width = 180 # Max width for PDF
|
| 176 |
+
pdf.image(img_buf, x=15, y=None, w=pdf_width, h=pdf_width * aspect)
|
| 177 |
+
|
| 178 |
+
pdf_buffer = io.BytesIO()
|
| 179 |
+
pdf.output(pdf_buffer)
|
| 180 |
+
pdf_buffer.seek(0)
|
| 181 |
+
return pdf_buffer
|
| 182 |
+
|