CoolFace
Apppublic

MOSES3377/ai-interview-app

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
pdf_report.py33 linesDownload Raw Back to root
1from fpdf import FPDF2 3class PDF(FPDF):4    def header(self):5        self.set_font("Arial", "B", 14)6        self.cell(0, 10, "AI Interview Report", 0, 1, "C")7 8    def footer(self):9        self.set_y(-15)10        self.set_font("Arial", "I", 8)11        self.cell(0, 10, f"Page {self.page_no()}", 0, 0, "C")12 13def generate_pdf(candidate_name, role, summary, questions, answers):14    pdf = PDF()15    pdf.add_page()16    pdf.set_font("Arial", "B", 16)17    pdf.cell(0, 10, f"Candidate: {candidate_name}", ln=True)18    pdf.set_font("Arial", "", 12)19    pdf.cell(0, 10, f"Role: {role}", ln=True)20    pdf.cell(0, 10, f"Overall Score: {summary.get('overall_score','N/A')}/10", ln=True)21    pdf.cell(0, 10, f"Recommendation: {summary.get('recommendation','N/A')}", ln=True)22    pdf.ln(10)23    pdf.set_font("Arial", "B", 14)24    pdf.cell(0, 10, "Detailed Q&A:", ln=True)25    pdf.ln(5)26    pdf.set_font("Arial", "", 12)27    for i, (q, a) in enumerate(zip(questions, answers), 1):28        pdf.multi_cell(0, 10, f"Q{i}: {q.get('text','')}")29        pdf.multi_cell(0, 10, f"Answer: {a.get('answer','')}")30        pdf.multi_cell(0, 10, f"Feedback: {a.get('feedback','')} (Score: {a.get('score','N/A')}/10)")31        pdf.ln(5)32    return pdf.output(dest="S").encode("latin-1")33