Saturday, 22 March 2025

from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas def generate_resume(name, email, phone, skills, experience, education, save_path): if not name or not email or not phone: raise ValueError("Please fill in all required fields.") c = canvas.Canvas(save_path, pagesize=letter) width, height = letter c.setFont("Helvetica-Bold", 16) c.drawCentredString(width / 2, height - 50, name) c.setFont("Helvetica", 12) c.drawCentredString(width / 2, height - 70, f"Email: {email} | Phone: {phone}") c.setFont("Helvetica-Bold", 14) c.drawString(50, height - 110, "Technical Skills") c.setFont("Helvetica", 12) c.drawString(50, height - 130, skills) c.setFont("Helvetica-Bold", 14) c.drawString(50, height - 160, "Professional Experience") c.setFont("Helvetica", 12) c.drawString(50, height - 180, experience) c.setFont("Helvetica-Bold", 14) c.drawString(50, height - 210, "Education") c.setFont("Helvetica", 12) c.drawString(50, height - 230, education) c.save() return "Resume saved successfully!" # Example usage: if __name__ == "__main__": sample_name = "John Doe" sample_email = "johndoe@example.com" sample_phone = "123-456-7890" sample_skills = "Python, Java, SQL" sample_experience = "Software Developer at XYZ Corp" sample_education = "B.Sc. Computer Science" sample_save_path = "resume.pdf" try: message = generate_resume(sample_name, sample_email, sample_phone, sample_skills, sample_experience, sample_education, sample_save_path) print(message) except ValueError as e: print(f"Error: {e}")

No comments:

Post a Comment

from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas def generate_resume(name, email, phone, skills, experience, ...