File size: 18,103 Bytes
41181c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2640be
41181c1
 
 
c2640be
41181c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2640be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41181c1
 
 
 
 
 
c2640be
41181c1
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
import gradio as gr
from fpdf import FPDF
import re
from docx import Document
from docx.shared import Pt, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH

class CustomPDF(FPDF):
    def header(self):
        if self.page_no() == 1:  # Only add image and personal details on the first page
            if self.image_path:
                self.image(self.image_path, x=150, y=20, w=40)
            
            self.set_font("Arial", 'B', 20)
            self.set_text_color(31, 73, 125)  # Set text color to the specific blue from the template
            self.cell(0, 10, 'Katrin Winter', ln=True, align='L')
            self.set_text_color(0, 0, 0)  # Reset text color to black
            self.set_font("Arial", '', 12)
            self.cell(0, 8, '10. Oktober 1991', ln=True, align='L')
            self.cell(0, 8, 'Kaiserstraße 1, 1010 Wien', ln=True, align='L')
            self.cell(0, 8, 'T +43 650 123 45 67', ln=True, align='L')
            self.cell(0, 8, 'E [email protected]', ln=True, align='L')
            self.ln(10)

    def section_title(self, title):
        self.set_font("Arial", 'B', 14)
        self.cell(0, 10, title, ln=True)
        self.ln(2)

    def add_experience(self, dates, role_company, description):
        self.set_font("Arial", '', 12)  # Regular font for dates
        
        # Clean up the text to ensure no excessive spaces
        dates = self.clean_text(dates)
        role_company = self.clean_text(role_company)
        description = self.clean_text(description)
        
        # Print the dates in template-specific blue color and move the cursor 5 cm from the left margin
        self.set_text_color(31, 73, 125)  # Set text color to the specific blue from the template
        self.cell(40, 8, dates, ln=False)
        self.set_text_color(0, 0, 0)  # Reset text color to black
        self.set_x(70)  # Move to 5 cm (50 mm) from the left margin
        self.set_font("Arial", 'B', 12)  # Bold for role and company
        self.cell(0, 8, role_company, ln=True)

        self.set_x(70)  # Move to 5 cm (50 mm) from the left margin for the description
        self.set_font("Arial", '', 12)  # Regular font for description
        self.multi_cell(0, 8, description)
        self.ln(3)

    def add_education(self, dates, degree_institution, details):
        self.set_font("Arial", '', 12)  # Regular font for dates
        
        # Clean up the text to ensure no excessive spaces
        dates = self.clean_text(dates)
        degree_institution = self.clean_text(degree_institution)
        details = self.clean_text(details)
        
        self.set_text_color(31, 73, 125)  # Set text color to the specific blue from the template
        self.cell(40, 8, dates, ln=False)
        self.set_text_color(0, 0, 0)  # Reset text color to black
        self.set_x(70)
        self.set_font("Arial", 'B', 12)  # Bold for degree and institution
        self.cell(0, 8, degree_institution, ln=True)
        self.set_font("Arial", '', 12)  # Regular font for details
        self.set_x(70)
        self.multi_cell(0, 8, details)
        self.ln(3)

    def add_qualification(self, year, qualification_institution, details):
        self.set_font("Arial", '', 12)  # Regular font for dates
        
        # Clean up the text to ensure no excessive spaces
        year = self.clean_text(year)
        qualification_institution = self.clean_text(qualification_institution)
        details = self.clean_text(details)
        
        self.set_text_color(31, 73, 125)  # Set text color to the specific blue from the template
        self.cell(40, 8, year, ln=False)
        self.set_text_color(0, 0, 0)  # Reset text color to black
        self.set_x(70)
        self.set_font("Arial", 'B', 12)  # Bold for qualification and institution
        self.cell(0, 8, qualification_institution, ln=True)
        self.set_font("Arial", '', 12)  # Regular font for details
        self.set_x(70)
        self.multi_cell(0, 8, details)
        self.ln(2)

    def add_skills(self, skills):
        self.set_font("Arial", '', 12)
        for skill in skills:
            self.set_x(70)
            self.cell(0, 8, f"{skill}", ln=True)
        self.ln(3)

    def add_languages(self, languages):
        self.set_font("Arial", '', 12)
        for language in languages:
            self.set_x(70)
            self.cell(0, 8, f"{language}", ln=True)
        self.ln(3)

    def add_interests(self, interests):
        self.set_font("Arial", '', 12)
        self.set_x(70)
        self.multi_cell(0, 8, f"{interests}")
        self.ln(3)

    def set_image(self, image_path):
        self.image_path = image_path

    def clean_text(self, text):
        # Replace multiple spaces with a single space and strip the text
        text = re.sub(r'\s+', ' ', text).strip()
        return text

def replace_special_characters(text):
    # Replace problematic characters with simpler ones
    return text.replace("–", "-").replace("’", "'").replace("‘", "'").replace("“", '"').replace("”", '"')

def create_resume(image, name, contact_info, 
                  experience_dates_1, experience_role_company_1, experience_description_1, 
                  experience_dates_2, experience_role_company_2, experience_description_2, 
                  education_dates_1, education_degree_institution_1, education_details_1,
                  education_dates_2, education_degree_institution_2, education_details_2,
                  qualification_year_1, qualification_institution_1, qualification_details_1,
                  qualification_year_2, qualification_institution_2, qualification_details_2,
                  skills, languages, interests):
    
    # Create PDF
    pdf = CustomPDF(orientation='P', unit='mm', format='A4')
    pdf.set_left_margin(20)
    pdf.set_right_margin(20)
    pdf.set_top_margin(20)
    pdf.set_auto_page_break(auto=True, margin=20)
    
    pdf.set_image(image)
    pdf.add_page()

    # Replace special characters in all fields
    name = replace_special_characters(name)
    contact_info = replace_special_characters(contact_info)
    experience_dates_1 = replace_special_characters(experience_dates_1)
    experience_role_company_1 = replace_special_characters(experience_role_company_1)
    experience_description_1 = replace_special_characters(experience_description_1)
    experience_dates_2 = replace_special_characters(experience_dates_2)
    experience_role_company_2 = replace_special_characters(experience_role_company_2)
    experience_description_2 = replace_special_characters(experience_description_2)
    education_dates_1 = replace_special_characters(education_dates_1)
    education_degree_institution_1 = replace_special_characters(education_degree_institution_1)
    education_details_1 = replace_special_characters(education_details_1)
    education_dates_2 = replace_special_characters(education_dates_2)
    education_degree_institution_2 = replace_special_characters(education_degree_institution_2)
    education_details_2 = replace_special_characters(education_details_2)
    qualification_year_1 = replace_special_characters(qualification_year_1)
    qualification_institution_1 = replace_special_characters(qualification_institution_1)
    qualification_details_1 = replace_special_characters(qualification_details_1)
    qualification_year_2 = replace_special_characters(qualification_year_2)
    qualification_institution_2 = replace_special_characters(qualification_institution_2)
    qualification_details_2 = replace_special_characters(qualification_details_2)
    skills = replace_special_characters(skills)
    languages = replace_special_characters(languages)
    interests = replace_special_characters(interests)

    # Experience
    pdf.section_title('Berufserfahrung')
    pdf.add_experience(experience_dates_1, experience_role_company_1, experience_description_1)
    pdf.add_experience(experience_dates_2, experience_role_company_2, experience_description_2)

    # Education
    pdf.section_title('Ausbildung')
    pdf.add_education(education_dates_1, education_degree_institution_1, education_details_1)
    pdf.add_education(education_dates_2, education_degree_institution_2, education_details_2)

    # Qualifications
    pdf.section_title('Qualifikationen')
    pdf.add_qualification(qualification_year_1, qualification_institution_1, qualification_details_1)
    pdf.add_qualification(qualification_year_2, qualification_institution_2, qualification_details_2)

    # Skills
    pdf.section_title('Kenntnisse')
    pdf.add_skills(["Microsoft Office: Ausgezeichnet", "Adobe Creative Suite: Ausgezeichnet", "HTML / CSS / CMS: Fortgeschritten"])

    # Languages
    pdf.section_title('Sprachen')
    pdf.add_languages(["Englisch: C1", "Spanisch: B2", "Italienisch: B2"])

    # Interests
    pdf.section_title('Interessen')
    pdf.add_interests("Fotografie, Reisen, Bergsteigen, Höhlentauchen")

    # Save the PDF to a file
    pdf_file = "resume_with_image.pdf"
    pdf.output(pdf_file)

    # Create Word Document
    doc = Document()
    doc.add_heading(name, 0).alignment = WD_ALIGN_PARAGRAPH.LEFT
    
    # Add contact info
    p = doc.add_paragraph()
    p.add_run(contact_info)
    
    # Add sections with content
    doc.add_heading('Berufserfahrung', level=1)
    doc.add_paragraph(f'{experience_dates_1} - {experience_role_company_1}\n{experience_description_1}')
    doc.add_paragraph(f'{experience_dates_2} - {experience_role_company_2}\n{experience_description_2}')
    
    doc.add_heading('Ausbildung', level=1)
    doc.add_paragraph(f'{education_dates_1} - {education_degree_institution_1}\n{education_details_1}')
    doc.add_paragraph(f'{education_dates_2} - {education_degree_institution_2}\n{education_details_2}')
    
    doc.add_heading('Qualifikationen', level=1)
    doc.add_paragraph(f'{qualification_year_1} - {qualification_institution_1}\n{qualification_details_1}')
    doc.add_paragraph(f'{qualification_year_2} - {qualification_institution_2}\n{qualification_details_2}')
    
    doc.add_heading('Kenntnisse', level=1)
    doc.add_paragraph(skills)
    
    doc.add_heading('Sprachen', level=1)
    doc.add_paragraph(languages)
    
    doc.add_heading('Interessen', level=1)
    doc.add_paragraph(interests)
    
    doc_file = "resume_with_image.docx"
    doc.save(doc_file)

    return pdf_file, doc_file

# Gradio Interface
inputs = [
    gr.Image(type="filepath", label="Profile Picture"),
    gr.Textbox(label="Name", placeholder="Katrin Winter", value="Katrin Winter"),
    gr.Textbox(label="Contact Information", placeholder="Address, Phone, Email", lines=4, value="10. Oktober 1991\nKaiserstraße 1, 1010 Wien\nT +43 650 123 45 67\nE [email protected]"),
    
    # Experience 1
    gr.Textbox(label="Experience 1 Dates", placeholder="02/2019 - jetzt", value="02/2019 - jetzt"),
    gr.Textbox(label="Experience 1 Role & Company", placeholder="B2B Marketing Manager\nStepcompany, Wien", value="B2B Marketing Manager\nStepcompany, Wien"),
    gr.Textbox(label="Experience 1 Description", placeholder="Selbstständige Organisation und Betreuung von Messen und Kundenevents, Aufbereitung von Sales- und Marketing-Materialien", lines=3, value="Selbstständige Organisation und Betreuung von Messen und Kundenevents, Aufbereitung von Sales- und Marketing-Materialien"),
    
    # Experience 2
    gr.Textbox(label="Experience 2 Dates", placeholder="02/2018 - 01/2019", value="02/2018 - 01/2019"),
    gr.Textbox(label="Experience 2 Role & Company", placeholder="Marketing Assistenz\nStepcompany, Wien", value="Marketing Assistenz\nStepcompany, Wien"),
    gr.Textbox(label="Experience 2 Description", placeholder="Abwicklung und Durchführung diverser Kundenprojekte, Einholung von Angeboten und Recherche von Give-Aways", lines=3, value="Abwicklung und Durchführung diverser Kundenprojekte, Einholung von Angeboten und Recherche von Give-Aways"),
    
    # Education 1
    gr.Textbox(label="Education 1 Dates", placeholder="02/2011 - 09/2016", value="02/2011 - 09/2016"),
    gr.Textbox(label="Education 1 Degree & Institution", placeholder="Wirtschafts- und Sozialwissenschaften, WU Wien", value="Wirtschafts- und Sozialwissenschaften, WU Wien"),
    gr.Textbox(label="Education 1 Details", placeholder="Schwerpunkt Marketing, Abschlussarbeit: Marktorientiertes Business Development", lines=3, value="Schwerpunkt Marketing, Abschlussarbeit: Marktorientiertes Business Development"),
    
    # Education 2
    gr.Textbox(label="Education 2 Dates", placeholder="02/2006 - 05/2011", value="02/2006 - 05/2011"),
    gr.Textbox(label="Education 2 Degree & Institution", placeholder="Marketingmanagement, HAK I, Vienna Business School", value="Marketingmanagement, HAK I, Vienna Business School"),
    gr.Textbox(label="Education 2 Details", placeholder="Details about this degree", lines=3, value=""),

    # Qualification 1
    gr.Textbox(label="Qualification 1 Year", placeholder="2019", value="2019"),
    gr.Textbox(label="Qualification 1 Institution", placeholder="Ausbildung Grafikdesign, Webeakademie Wien", value="Ausbildung Grafikdesign, Webeakademie Wien"),
    gr.Textbox(label="Qualification 1 Details", placeholder="Details about this qualification", lines=3, value=""),

    # Qualification 2
    gr.Textbox(label="Qualification 2 Year", placeholder="2018", value="2018"),
    gr.Textbox(label="Qualification 2 Institution", placeholder="Online-Marketing Basis-Lehrgang, Online Marketing Forum, Wien", value="Online-Marketing Basis-Lehrgang, Online Marketing Forum, Wien"),
    gr.Textbox(label="Qualification 2 Details", placeholder="Details about this qualification", lines=3, value=""),

    # Other sections
    gr.TextArea(label="Kenntnisse", placeholder="Enter skills here", lines=3, value="""
Microsoft Office: Ausgezeichnet
Adobe Creative Suite: Ausgezeichnet
HTML / CSS / CMS: Fortgeschritten
    """),
    gr.TextArea(label="Sprachen", placeholder="Enter languages here", lines=3, value="""
Englisch: C1
Spanisch: B2
Italienisch: B2
    """),
    gr.TextArea(label="Interessen", placeholder="Enter interests here", lines=2, value="Fotografie, Reisen, Bergsteigen, Höhlentauchen")
]

outputs = [
    gr.File(label="Download Your Resume as PDF"),
    gr.File(label="Download Your Resume as DOCX")
]

examples = [
    [
        "profile_picture.jpg",
        "Alexander Meyer",
        "15. März 1985\nLeopoldstraße 45, 80333 München\nT +49 89 123 45 67\nE [email protected]",
        "03/2017 - jetzt", "Senior Marketing Manager\nTechSolutions AG, München", "Führung des Marketing-Teams, Entwicklung und Implementierung von Marketingstrategien, Budgetverwaltung und Performance-Analyse.",
        "05/2014 - 02/2017", "Marketing Specialist\nMedia Group GmbH, München", "Durchführung von Marktforschung, Unterstützung bei der Planung und Durchführung von Marketingkampagnen, Erstellung von Content und Werbematerialien.",
        "10/2005 - 07/2010", "Betriebswirtschaftslehre, LMU München", "Schwerpunkt Marketing, Abschlussarbeit: 'Die Rolle von Social Media im modernen Marketing.'",
        "09/2000 - 06/2005", "Wirtschaftsgymnasium, München", "Allgemeine Hochschulreife mit Schwerpunkt Wirtschaft.",
        "2018", "Google Analytics Zertifizierung, Google", "",
        "2016", "Projektmanagement, IHK München", "",
        "Microsoft Office: Ausgezeichnet\nGoogle Ads: Ausgezeichnet\nSEO/SEM: Fortgeschritten",
        "Englisch: C2\nFranzösisch: B1",
        "Laufen, Lesen, Reisen"
    ],
    [
        "profile_picture2.jpg",
        "Lena Schmidt",
        "02. Februar 1990\nFriedrichstraße 10, 10117 Berlin\nT +49 30 765 4321\nE [email protected]",
        "06/2018 - jetzt", "Art Director\nCreative Agency Berlin", "Leitung des Design-Teams, Entwicklung visueller Konzepte, enge Zusammenarbeit mit Kunden zur Umsetzung kreativer Projekte.",
        "08/2015 - 05/2018", "Grafikdesignerin\nDesign Studio GmbH, Berlin", "Gestaltung von Print- und Digitalmedien, Erstellung von Logos, Layouts und Branding-Materialien.",
        "10/2008 - 07/2012", "Kommunikationsdesign, Universität der Künste Berlin", "Schwerpunkt Grafikdesign, Abschlussarbeit: 'Visuelle Kommunikation in der digitalen Ära.'",
        "09/2004 - 06/2008", "Gymnasium, Berlin", "Allgemeine Hochschulreife.",
        "2017", "UX/UI Design Kurs, Interaction Design Foundation", "",
        "2014", "Adobe Certified Expert, Adobe", "",
        "Adobe Creative Suite: Ausgezeichnet\nSketch: Fortgeschritten\nHTML/CSS: Grundkenntnisse",
        "Englisch: C1\nSpanisch: A2",
        "Fotografie, Zeichnen, Reisen"
    ],
    [
        "profile_picture3.jpg",
        "Jonas Müller",
        "12. Dezember 1988\nAm Seestern 24, 40219 Düsseldorf\nT +49 211 987 6543\nE [email protected]",
        "01/2016 - jetzt", "IT Systems Engineer\nDataTech Solutions, Düsseldorf", "Verwaltung und Wartung von IT-Systemen, Netzwerkadministration, Sicherstellung der IT-Sicherheit, Betreuung der IT-Infrastruktur.",
        "09/2012 - 12/2015", "IT Support Specialist\nInfoTech GmbH, Düsseldorf", "Technischer Support für Mitarbeiter, Fehlerbehebung und Systemupdates, Betreuung der internen IT-Systeme.",
        "10/2007 - 07/2011", "Informatik, Heinrich-Heine-Universität Düsseldorf", "Schwerpunkt Netzwerkadministration, Abschlussarbeit: 'Sicherheitslösungen in modernen Netzwerken.'",
        "09/2002 - 06/2007", "Fachoberschule für Technik, Düsseldorf", "Allgemeine Fachhochschulreife mit Schwerpunkt Informationstechnik.",
        "2018", "Cisco Certified Network Associate (CCNA), Cisco", "",
        "2017", "ITIL Foundation, AXELOS", "",
        "Netzwerkadministration: Ausgezeichnet\nVirtualisierung (VMware, Hyper-V): Fortgeschritten\nLinux: Fortgeschritten",
        "Englisch: C1\nDeutsch: Muttersprache",
        "Programmieren, Wandern, Gaming"
    ]
]

gr_interface = gr.Interface(
    fn=create_resume, 
    inputs=inputs, 
    outputs=outputs,
    title="Resume Creator",
    description="Create a resume similar to the provided template.",
    examples=examples
)

gr_interface.launch()