Resume Generation With Python

by IoFAdmin at

python | programming

Let's Make A Resume That Stands Out

With the Covid pandemic, everyone seems to be changing jobs and updating their resumes. Many work from home jobs receive hundreds of applicants so you need something to differentiate your resume from all of the others. Follow along Random Internet Stranger as we create an eye-pleasing resume that will get you a first interview... you're on your own after that!

First Steps

To complete this tutorial (and make it rain with that new high paying job), you'll need PDFKit which you can install with:

pip install pdfkit  (or pip3 for python3)

Project Overview

  • Create a HTML layout of our resume
  • Write a Python script to generate a PDF of the resume
  • Live a life of luxury with a new job*

*results not guaranteed

Step 0 - Planning

This kind of goes without saying but I'm saying it anyway.... plan ahead and gather your information. What jobs do you want to list? What were the dates you worked there? What skills do you want to highlight? Do you have any special projects that you'd like interviewers to know about?

Step 1 - HTML Content and CSS Layout

For this step, we're going to create a webpage version of your resume which is totally self-contained without loading any external CSS files. Feel free to use my example as a starting point and modify it to suit your needs. Enough talk! Show me the markup!

Resume Markup

Create a file named resume_sample.html and enter the following markup into it:

<!DOCTYPE HTML>
<html lang="en">
<head>
	<title>Test Guy's Resume</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
	<style>
		body {
			margin: 0;
			padding: 0;
			font-family: 'Calibri';
                        font-size:11px;
		}

		a {
			text-decoration: none;
			color: inherit;
		}

		.box1 {
                     width: 28%;
                     height:90%;
                     float: left;
		     background-color: #370D32;
		    color: white;
                    padding-left: 7em;
                    padding-top:1.5em;
		}

		.box2 {
                     width: 60%;
                     float: left;
                     height:90%;
                     padding-left: 1.25em;
                    padding-right: 0.75em;
                    padding-top:0.75em;
		}

		.cols {
                     padding-bottom: 100%;
                     margin-bottom: -100%;
		}

		.box1 h1{
			font-weight: bold;
			font-size: 2.75em;
			margin:0;
			padding:0;
		}

		.box1 h2{
			font-weight: bold;
			font-size: 1.75em;
			margin: 1.25em 0 0 0;
		}

		.box1 .jobtitle {
			margin:0.25em 0 0 0;
			padding:0;
		} 

		.box1 ul {
			list-style: none;
			margin: 0 0 0 0;
			padding-left: 0;
			font-size: 1.5em;
		}

              .box2 ul {
			margin: 0 0 1.5em 0;
		}

		.box1 li {
			line-height: 1.5em;
		}

		.box2 h2, .box2 h3, .box2 p {
			margin: 0 0 0.2em 0;
		}

		.box2 p {
                     margin:0.25em 0 1em 0;
		}

		.box2 h3 {
			color: #696969;
		}

		progress {
                     border: 0;
                     height: 0.5em;
                     border-radius: 9px;
                     margin-top: 0.2em;
                     margin-bottom: 0.6em;
		}

		/* background: */
		progress::-webkit-progress-bar {background-color: #696969; width: 100%;}
		progress {background-color: #696969;}

		/* value: */
		progress::-webkit-progress-value {background-color: #fff !important;}
		progress::-moz-progress-bar {background-color: #fff !important;}
		progress {color: green;}

		hr {
			margin:0 0 0 5.25em;
			width:20%;
		}
	</style>
	</head>
	<body>
  		<div class="box1 cols">
  			<h1>Test Guy</h1>
			<hr>
  			<h2 class="jobtitle">Widget Maker</h2>

  			<h2>Contact Details</h2>
  			<ul>
  				<li>Anytown, USA</li>
  				<li>123-555-4321</li>
  				<li>test.guy@gmail.com</li>
  			</ul>

  			<h2>Skills</h2>
  			<ul>
  				<li>Widget Making<br><progress value="100" max="100"></progress></li>
				<li>Widget Reports<br><progress value="100" max="100"></progress></li>
				<li>Coffee Breaks<br><progress value="80" max="100"></progress></li>
				<li>Widget Testing<br><progress value="70" max="100"></progress></li>
				<li>Excel<br><progress value="100" max="100"></progress></li>
				<li>Widget Inventory<br><progress value="80" max="100"></progress></li>
				<li>Widget Development<br><progress value="80" max="100"></progress></li>
				<li>Singing<br><progress value="70" max="100"></progress></li>
				<li>Piano<br><progress value="60" max="100"></progress></li>
				<li>Blogging<br><progress value="100" max="100"></progress></li>
				<li>Widgetifcation<br><progress value="70" max="100"></progress></li>
  			</ul>
  		</div>
  		<div class="box2 cols">
  			<h1>Profile</h1>
  			<p>Widget Maker with more than 10 years of industry-standard widget experience.</p>

  			<h1>Employment History</h1>

  			<h2>Widget Maker, Widgets Inc, Anytown, USA</h2>
				<h3>2018 to Present</h3>
                <ul>
                    <li>Oversee widget production in the factory</li>
                    <li>Sed ut perspiciatis unde omnis iste natus error</li>
                    <li>Nemo enim ipsam voluptatem quia voluptas sit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing eli</li>
                    <li>Ut enim ad minim veniam, quis nostrud exercitation</li>
                </ul>

				<h2>Widget Master, Widgets For You, Anytown, USA</h2>
				<h3>2016 to January 2018</h3>
				<ul>
                    <li>Widget production and manage widget tests</li>
                    <li>Sed ut perspiciatis unde omnis iste natus error</li>
                    <li>Nemo enim ipsam voluptatem quia voluptas sit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing eli</li>
                    <li>Ut enim ad minim veniam, quis nostrud exercitation</li>
                </ul>

				<h2>Widget Guy, Another Company, Anytown, USA</h2>
				<h3>2015 to December 2016</h3>
				<ul>
                    <li>Increase widget production by 37%</li>
                    <li>Nemo enim ipsam voluptatem quia voluptas sit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing eli</li>
                </ul>

				<h2>Widget Pro, That Widget Company, Anytown, USA</h2>
				<h3>2010 to 2015</h3>
				<ul>
                    <li>Do something with widgets</li>
                    <li>Sed ut perspiciatis unde omnis iste natus error</li>
                    <li>Nemo enim ipsam voluptatem quia voluptas sit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing eli</li>
                    <li>Ut enim ad minim veniam, quis nostrud exercitation</li>
                </ul>

				<h1>Projects</h1>

				<h2>My Widgets, <a target="_blank" href="https://www.google.com/">https://www.somefakeurl.com/</a></h2>
				<h3>2019 to Present</h3>
				<ul>
                    <li>Widget making tutorial site</li>
                    <li>Sell widgets</li>
                </ul>

				<h2>Volunteering</h2>
				<h3>2021 to Present</h3>
				<ul>
                    <li>Volunteer with kids who have no widgets</li>
                    <li>Neque porro quisquam est, qui dolorem ipsum quia</li>
                    <li>Quis autem vel eum iure reprehenderit qui</li>
                </ul>

                <h1>Education</h1>

                <h2>Bachelor of Science in Widgets</h2>
                <p>Widget University - Anytown, USA - October 2010</p>

                <h2>Widget Cerification</h2>
                <p>Widget Training Center - Anytown, USA - December 2009</p>
  		</div>
	</body>
</html>

Step 2 - Create Our Python Script

Create Python script named generate.py and enter the following code into it:

import pdfkit 

options = {
    'page-size': 'Letter',
    'margin-top': '0in',
    'margin-right': '0in',
    'margin-bottom': '0in',
    'margin-left': '0in',
    'encoding': "UTF-8",
    'custom-header': [
        ('Accept-Encoding', 'gzip')
    ],
    'no-outline': None
}

pdfkit.from_file('resume_sample.html', 'resume_sample.pdf', options=options)

Step 3 - Generate the PDF

Run the generate.py script with the HTML file in the same directory. If everything worked, you should a fancy PDF version of your resume.

Disclaimer

I have seen the error of a second blank page being added at the end of the PDF. This is easily solvable by printing the PDF to a file and only including the first page. If you know how to stop the second page from being generated, I'd love to hear your solution.

Let's See What We Made

Step 4 - Make It Your Own

Feel free to modify the layout, colors, fonts, etc. however you want. Obviously, you'll need to replace our test content with the real content that you gathered in Step 0. Good luck with your job hunt!