atifsial123 commited on
Commit
bd4baae
1 Parent(s): ff73789

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -33
app.py CHANGED
@@ -3,17 +3,17 @@ from fpdf import FPDF
3
  from PIL import Image
4
 
5
  # Function to generate the CV PDF with an uploaded photo
6
- def generate_pdf(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, gpa, work_title, work_company, work_dates, work_responsibility, skills, certifications, projects, awards, references, photo):
7
  pdf = FPDF()
8
  pdf.add_page()
9
 
10
  # Add Title
11
  pdf.set_font("Arial", 'B', 16)
12
- pdf.cell(200, 10, txt="CV", ln=True, align='C') # Changed title to "CV"
13
 
14
  # Add photo if provided
15
  if photo:
16
- pdf.image(photo, x=10, y=10, w=30) # Adjust image placement and size
17
 
18
  # Move the cursor below the image
19
  pdf.ln(40)
@@ -29,10 +29,10 @@ def generate_pdf(full_name, phone, email, linkedin, address, title, summary, deg
29
  pdf.cell(200, 10, txt=f"Address: {address}", ln=True)
30
  pdf.cell(200, 10, txt=f"Professional Title: {title}", ln=True)
31
 
32
- # Professional Summary
33
- pdf.cell(200, 10, txt="", ln=True) # Empty line
34
  pdf.set_font("Arial", 'B', 12)
35
- pdf.cell(200, 10, txt="Professional Summary", ln=True)
36
  pdf.set_font("Arial", '', 12)
37
  pdf.multi_cell(200, 10, txt=summary)
38
 
@@ -44,8 +44,8 @@ def generate_pdf(full_name, phone, email, linkedin, address, title, summary, deg
44
  pdf.cell(200, 10, txt=f"Degree: {degree}", ln=True)
45
  pdf.cell(200, 10, txt=f"University: {university}", ln=True)
46
  pdf.cell(200, 10, txt=f"Graduation Date: {graduation}", ln=True)
47
- if gpa:
48
- pdf.cell(200, 10, txt=f"GPA: {gpa}", ln=True)
49
 
50
  # Work Experience
51
  pdf.cell(200, 10, txt="", ln=True)
@@ -64,33 +64,26 @@ def generate_pdf(full_name, phone, email, linkedin, address, title, summary, deg
64
  pdf.set_font("Arial", '', 12)
65
  pdf.multi_cell(200, 10, txt=skills)
66
 
67
- # Certifications
68
- pdf.cell(200, 10, txt="", ln=True)
69
- pdf.set_font("Arial", 'B', 12)
70
- pdf.cell(200, 10, txt="Certifications", ln=True)
71
- pdf.set_font("Arial", '', 12)
72
- pdf.multi_cell(200, 10, txt=certifications)
73
-
74
- # Projects
75
  pdf.cell(200, 10, txt="", ln=True)
76
  pdf.set_font("Arial", 'B', 12)
77
- pdf.cell(200, 10, txt="Projects", ln=True)
78
  pdf.set_font("Arial", '', 12)
79
- pdf.multi_cell(200, 10, txt=projects)
80
 
81
- # Awards
82
  pdf.cell(200, 10, txt="", ln=True)
83
  pdf.set_font("Arial", 'B', 12)
84
- pdf.cell(200, 10, txt="Awards and Achievements", ln=True)
85
  pdf.set_font("Arial", '', 12)
86
- pdf.multi_cell(200, 10, txt=awards)
87
 
88
- # References
89
  pdf.cell(200, 10, txt="", ln=True)
90
  pdf.set_font("Arial", 'B', 12)
91
- pdf.cell(200, 10, txt="References", ln=True)
92
  pdf.set_font("Arial", '', 12)
93
- pdf.multi_cell(200, 10, txt=references)
94
 
95
  # Save the PDF
96
  pdf_file = "generated_cv_with_photo.pdf"
@@ -99,13 +92,13 @@ def generate_pdf(full_name, phone, email, linkedin, address, title, summary, deg
99
  return pdf_file
100
 
101
  # Gradio interface to get input from user and generate CV with photo
102
- def create_cv_with_photo(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, gpa, work_title, work_company, work_dates, work_responsibility, skills, certifications, projects, awards, references, photo):
103
  # Save the uploaded photo temporarily
104
  if photo:
105
  photo.save("uploaded_photo.jpg")
106
- pdf_file = generate_pdf(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, gpa, work_title, work_company, work_dates, work_responsibility, skills, certifications, projects, awards, references, "uploaded_photo.jpg")
107
  else:
108
- pdf_file = generate_pdf(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, gpa, work_title, work_company, work_dates, work_responsibility, skills, certifications, projects, awards, references, None)
109
 
110
  return pdf_file
111
 
@@ -119,20 +112,19 @@ iface = gr.Interface(
119
  gr.Textbox(label="LinkedIn Profile"),
120
  gr.Textbox(label="Address"),
121
  gr.Textbox(label="Professional Title"),
122
- gr.Textbox(label="Professional Summary"),
123
  gr.Textbox(label="Degree"),
124
  gr.Textbox(label="University/Institution"),
125
  gr.Textbox(label="Graduation Date"),
126
- gr.Textbox(label="GPA (optional)"),
127
  gr.Textbox(label="Work Title"),
128
  gr.Textbox(label="Company Name"),
129
  gr.Textbox(label="Dates of Employment"),
130
  gr.Textbox(label="Work Responsibilities", lines=4),
131
  gr.Textbox(label="Skills", lines=3),
132
- gr.Textbox(label="Certifications and Training", lines=2),
133
- gr.Textbox(label="Projects", lines=2),
134
- gr.Textbox(label="Awards", lines=2),
135
- gr.Textbox(label="References", lines=2),
136
  gr.Image(type="pil", label="Upload Photo (optional)"),
137
  ],
138
  outputs=gr.File(label="Download PDF CV"),
@@ -142,3 +134,5 @@ iface = gr.Interface(
142
 
143
  # Launch the interface
144
  iface.launch()
 
 
 
3
  from PIL import Image
4
 
5
  # Function to generate the CV PDF with an uploaded photo
6
+ def generate_pdf(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, courses, work_title, work_company, work_dates, work_responsibility, skills, achievements, extracurricular, certifications, photo):
7
  pdf = FPDF()
8
  pdf.add_page()
9
 
10
  # Add Title
11
  pdf.set_font("Arial", 'B', 16)
12
+ pdf.cell(200, 10, txt="CV", ln=True, align='C')
13
 
14
  # Add photo if provided
15
  if photo:
16
+ pdf.image(photo, x=10, y=10, w=30)
17
 
18
  # Move the cursor below the image
19
  pdf.ln(40)
 
29
  pdf.cell(200, 10, txt=f"Address: {address}", ln=True)
30
  pdf.cell(200, 10, txt=f"Professional Title: {title}", ln=True)
31
 
32
+ # Professional Summary/Objective
33
+ pdf.cell(200, 10, txt="", ln=True)
34
  pdf.set_font("Arial", 'B', 12)
35
+ pdf.cell(200, 10, txt="Professional Summary/Objective", ln=True)
36
  pdf.set_font("Arial", '', 12)
37
  pdf.multi_cell(200, 10, txt=summary)
38
 
 
44
  pdf.cell(200, 10, txt=f"Degree: {degree}", ln=True)
45
  pdf.cell(200, 10, txt=f"University: {university}", ln=True)
46
  pdf.cell(200, 10, txt=f"Graduation Date: {graduation}", ln=True)
47
+ if courses:
48
+ pdf.multi_cell(200, 10, txt=f"Relevant Courses: {courses}")
49
 
50
  # Work Experience
51
  pdf.cell(200, 10, txt="", ln=True)
 
64
  pdf.set_font("Arial", '', 12)
65
  pdf.multi_cell(200, 10, txt=skills)
66
 
67
+ # Achievements
 
 
 
 
 
 
 
68
  pdf.cell(200, 10, txt="", ln=True)
69
  pdf.set_font("Arial", 'B', 12)
70
+ pdf.cell(200, 10, txt="Achievements", ln=True)
71
  pdf.set_font("Arial", '', 12)
72
+ pdf.multi_cell(200, 10, txt=achievements)
73
 
74
+ # Volunteer/Extracurricular Activities
75
  pdf.cell(200, 10, txt="", ln=True)
76
  pdf.set_font("Arial", 'B', 12)
77
+ pdf.cell(200, 10, txt="Volunteer/Relevant Extracurricular Activities", ln=True)
78
  pdf.set_font("Arial", '', 12)
79
+ pdf.multi_cell(200, 10, txt=extracurricular)
80
 
81
+ # Certifications/Licenses
82
  pdf.cell(200, 10, txt="", ln=True)
83
  pdf.set_font("Arial", 'B', 12)
84
+ pdf.cell(200, 10, txt="Certifications/Licenses", ln=True)
85
  pdf.set_font("Arial", '', 12)
86
+ pdf.multi_cell(200, 10, txt=certifications)
87
 
88
  # Save the PDF
89
  pdf_file = "generated_cv_with_photo.pdf"
 
92
  return pdf_file
93
 
94
  # Gradio interface to get input from user and generate CV with photo
95
+ def create_cv_with_photo(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, courses, work_title, work_company, work_dates, work_responsibility, skills, achievements, extracurricular, certifications, photo):
96
  # Save the uploaded photo temporarily
97
  if photo:
98
  photo.save("uploaded_photo.jpg")
99
+ pdf_file = generate_pdf(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, courses, work_title, work_company, work_dates, work_responsibility, skills, achievements, extracurricular, certifications, "uploaded_photo.jpg")
100
  else:
101
+ pdf_file = generate_pdf(full_name, phone, email, linkedin, address, title, summary, degree, university, graduation, courses, work_title, work_company, work_dates, work_responsibility, skills, achievements, extracurricular, certifications, None)
102
 
103
  return pdf_file
104
 
 
112
  gr.Textbox(label="LinkedIn Profile"),
113
  gr.Textbox(label="Address"),
114
  gr.Textbox(label="Professional Title"),
115
+ gr.Textbox(label="Professional Summary/Objective"),
116
  gr.Textbox(label="Degree"),
117
  gr.Textbox(label="University/Institution"),
118
  gr.Textbox(label="Graduation Date"),
119
+ gr.Textbox(label="Relevant Courses (optional)", lines=2),
120
  gr.Textbox(label="Work Title"),
121
  gr.Textbox(label="Company Name"),
122
  gr.Textbox(label="Dates of Employment"),
123
  gr.Textbox(label="Work Responsibilities", lines=4),
124
  gr.Textbox(label="Skills", lines=3),
125
+ gr.Textbox(label="Achievements", lines=2),
126
+ gr.Textbox(label="Volunteer/Extracurricular Activities", lines=2),
127
+ gr.Textbox(label="Certifications/Licenses", lines=2),
 
128
  gr.Image(type="pil", label="Upload Photo (optional)"),
129
  ],
130
  outputs=gr.File(label="Download PDF CV"),
 
134
 
135
  # Launch the interface
136
  iface.launch()
137
+
138
+