ATS.CV / app.py
SamiKhokhar's picture
Update app.py
9e65b18 verified
class ResumeBuilder(FPDF):
def header(self):
self.set_font("Arial", "B", 16)
self.set_text_color(50, 50, 50)
self.cell(0, 10, "ATS-Friendly Resume", align="C", ln=True)
self.ln(10)
def add_section(self, title, content):
self.set_font("Arial", "B", 12)
self.set_text_color(50, 50, 50)
self.cell(0, 10, title, ln=True)
self.set_font("Arial", "", 12)
self.set_text_color(80, 80, 80)
self.multi_cell(0, 10, content)
self.ln(5)
def add_image(self, image):
# Open the image
image = Image.open(image)
# Convert image to RGB (remove alpha channel if it exists)
if image.mode == "RGBA":
image = image.convert("RGB")
# Save the image in a temporary file in a format that FPDF accepts (JPEG)
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
image.save(temp_file, "JPEG") # Ensure the image is saved as JPEG
temp_file_path = temp_file.name
# Add the image to the PDF
self.image(temp_file_path, x=10, y=self.get_y(), w=30, h=30)
self.set_y(self.get_y() + 35)
def add_social_icons(self, linkedin=None, email=None, phone=None):
self.set_font("Arial", "B", 12)
self.cell(0, 10, "Contact Information:", ln=True)
self.set_font("Arial", "", 12)
if linkedin:
self.cell(0, 10, f"LinkedIn: [icon]({linkedin})", ln=True)
if email:
self.cell(0, 10, f"Email: [icon]({email})", ln=True)
if phone:
self.cell(0, 10, f"Phone: {phone}", ln=True)
self.ln(5)
def add_skills(self, skills, title="Skills"):
self.set_font("Arial", "B", 12)
self.cell(0, 10, title, ln=True)
self.set_font("Arial", "", 12)
self.multi_cell(0, 10, "\n".join(skills))
self.ln(5)