Previously, I’ve written on how to create Abstract book easily. Today, another friend asked for help with generation of badges for attendees of a conference he is co-organising. We have automatised the process for #NGSchool. You can find templates and code in my github repo: https://github.com/lpryszcz/badges
First of all, for our courses we need to create user accounts for all participants in remote machines. Therefore we decided to print user data (username and auto-generated password) on the back of every badge (easy to fold). And since user data are auto-generated, we can easily create user accounts in remote machines using
newusers. But for a conference, this can be skipped.
All you need to have to start is
- tab-delimited file with first name, surname and affiliation
- badge template
badges.svgfor example generated by Inkscape (I have provided two templates we’ve been using lately)
badges.svg template, the easiest way to go is to create new
.svg with the prototype of 1 badge. Make sure instead to put in your badge “Name surname”, “username” and “AFFILIATION” that will be replaced by every attendees data. Once you created single badge (make sure it’s right size!). Then add some border (light grey dots?) in order to facilitate easier cutting. Finally, copy your badge to fill entire A4 page – you can easily fit 9 badges per A4 page.
Once you have the above, simply execute below commands.
# if you need to generate random passwords
# generate pdf with badges
./tsv2badges.py badges.svg participants.txt.badges.tsv
# you can create user accounts easily if needed
while read line; do if [ ! -d `echo $line | cut -f6 -d":"` ]; then echo $line; echo $line | sudo newusers; fi; done < participants.txt.newusers
tsv2badges.py takes user data and fills svg with them. Once given page is full, it stores it as .pdf and proceed to another page. At the end all pages are merged into one pdf with multiple pages
badges.svg.pdf that you should print & cut.