Spaces:
Sleeping
Sleeping
File size: 2,273 Bytes
3504eb7 a665d76 3504eb7 a665d76 3504eb7 a665d76 3504eb7 a665d76 3504eb7 a665d76 3504eb7 71dc843 a665d76 371bfce a665d76 71dc843 a665d76 71dc843 a665d76 71dc843 a665d76 | 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
def generate_pdf_report(analysis, is_pro=False):
filename = "report.pdf"
doc = SimpleDocTemplate(filename, pagesize=A4)
styles = getSampleStyleSheet()
elements = []
# Nadpis
elements.append(Paragraph(f"Resume Analysis Score: {analysis.get('match_score', 0)}/100", styles['Title']))
elements.append(Spacer(1, 12))
# NOVÉ: Kariérní doporučení
elements.append(Paragraph("Kariérní doporučení a vhodnost:", styles['Heading2']))
elements.append(Paragraph(analysis.get("career_recommendations", "Nebylo vygenerováno."), styles['Normal']))
elements.append(Spacer(1, 12))
# Chybějící klíčová slova
elements.append(Paragraph("Chybějící klíčová slova:", styles['Heading2']))
kw_data = [["Klíčové slovo", "Proč je důležité"]]
for kw in analysis.get("missing_keywords", []):
if isinstance(kw, dict):
kw_data.append([kw.get("keyword", ""), kw.get("why_it_matters", "")])
else:
kw_data.append([str(kw), ""])
table = Table(kw_data, colWidths=[150, 300])
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('GRID', (0, 0), (-1, -1), 1, colors.black),
]))
elements.append(table)
elements.append(Spacer(1, 12))
# Tvoje akce
elements.append(Paragraph("Tvoje 3 nejdůležitější akce:", styles['Heading2']))
for action in analysis.get("top_3_actions", []):
text = action if isinstance(action, str) else str(action)
elements.append(Paragraph(f"- {text}", styles['Normal']))
elements.append(Spacer(1, 12))
# ATS Varování
elements.append(Paragraph("ATS Varování:", styles['Heading2']))
for warn in analysis.get("ats_warnings", []):
text = warn if isinstance(warn, str) else str(warn)
elements.append(Paragraph(f"- {text}", styles['Normal']))
# Sestavení PDF
doc.build(elements)
return filename |