Create limitless number of name tags instantly

Imagine you are organizing an event. That might be a conference, a lecture, a talk or basically everything where a bunch of people might show up to. Those people, probably from different states/countries don’t know each other and you want to help them out with that? Excellent! Just give them name tags… But… wait… That is a lot of work! Mmhm – let the HIWI* do it! Great idea!

That’s what I imagine in my head when I get these jobs…

The objective is clear. You get a (very large) excel sheet with surnames, names and the university of every attending person. You are expected to create a decent looking name tag for everyone on that list, print it and put it into the wrapper.

Last time I tried using Microsoft Word’s (or OpenOffice’s) Mass Mail function – with success. But unfortunately I ended up printing one name tag on one piece of paper. That might be because I found that whole process very confusing or because it is actually not meant to be used that way – whatever. This time i wanted to do it right.

So how does one do it right as a Computer Science student you might ask? Well, we write an application for that!

nametag_example
It will look something like this…

This time I used PHP. It is actually a very simple application too – you don’t need any advanced coding skills to use it. It takes a .csv file (which you can create by saving your excel or OpenOffice Calc document as .csv) and writes the name of each person in that list to an image and prints the resulting images.

So how does it work?

The following files are all in the same directory. First I will show you the complete code of each file and then I will explain in detail what it does and how you can change it according to your needs.

Very self explanatory. You open the nametags file – which is saved as “nametags.csv” and located in the same directory – and loop through every entry to create the image for every person that attends your conference. Note: We tell the script what name to render by adding the variable “name” consisting of surname + name in this case. You might not want to do that or tweak it a little bit to your needs here. I also set the width and the height of the image to the actual size of my name tag wrapper (so it fits!) – again – you might want to change that. I recommend though, that you create the actual background image in a much larger resolution and downscale it like I did here – this will result in a much sharper result and a very fancy name tag.

This is the most complicated part. But it is still very easy. In the beginning we define the variables that we need. Note: The Font names are actual files located in the same directory. They must be in the .ttf format. You can find free ttf fonts here.

First we write the name onto the image. I made it so a very long name (Note: Name consists here of surname+name) gets written in a slightly smaller font depending on the actual size of it.

The .csv file is also no miracle. You add a new line for every name tag that you want to create and the script will take care of the rest. Make sure that you use the right delimiters though!

How do I use it?
  1. Just create these files and make sure they are all located in the same directory.
  2. Create an image that you want to use as the background
  3. Upload/Move everything to your Webserver location
  4. Navigate to the location of the index.php with any browser
  5. Profit!

The script should give you easily printable name tags for every single name in your csv file. You can then print the whole page (make sure it does not cut through a name tag in the print preview!) and save paper, the environment and nerves.

nametags_final
The background image i used

You know what the best part is? Every “pls-create-1000-name-tags-job” from now on will be a piece of cake.

*HIWI: (underpaid) Person working for a university. Mostly¬†broke students…

Leave a Reply

Your email address will not be published. Required fields are marked *