Spaces:
Sleeping
Sleeping
| 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 |