Con-Badges
Application for creating unique event badges for attendees using SVG templates. Many events use a variety of badges for different attendee types and access levels. This software allows you to generate personalized badges of a variety of types. Badges can be printed from attendee data loaded from a CSV file or by polling a web service you provide. The badges are defined by types. Each type can have a separate SVG template file to define it's appearance. The SVG is dynamically modified based on the loaded badge data. For example the SVG template might include a text element named "FIRST_NAME" which is replaced with the person's first name. In addition, the software can generate a QR Code and a Barcode based on user data which can be positioned in the SVG template.

The software can either generate PNG images for each badge or print the badges to a printer. At the moment the software assumes that you are generating 4"x6" badges and has only been tested using a HiTi P720L photo printer. For now, if you want to use another printer or badge size you will need to modify constants in the BadgePrinter.java.
Usage
The software will look for a folder called "badgedata" in the current directory. It expects to find the definition of badge types, SVG templates and necessary pictures here.
There are two modes of operation. From the Options menu you can select "Print Badges" or "Generate PNG Files". "Print Badges" instructs the software to generate badge images in memory and send them directly to a printer. "Generate PNG Files" instructs the software to generate PNG images for each badge and store them in the "con-badges" folder inside your home directory.
When the software starts up, it is initially stopped. You can use the "Start Processing" menu option to begin generating badges. Processing can be stopped at any time and can be restarted. This is useful if your printer runs out of paper and you want to pause printing until you have added paper.
The project includes a sample configuration in the "sample/badgedata/" folder. You can use this as a reference for creating templates and configurations for your event.
Badge data can be loaded from comma separated value (CSV) files. MS Excel and many other applications can export CSV files. The software assumes that the first line of data contains column headers and the remaining lines each contain data for one badge.
badges.csvID_USER,ID_BADGE,TYPE,BADGE_NAME,ORGANIZATION,BARCODE,QRCODE
10000,1000,attendee,Rose,Bad Wolf Club,10000-1000,http://rjenks.github.io/Con-Badges
10001,1001,pre-registered,Marty,Doc Brown Science,10001-1001,http://rjenks.github.io/Con-Badges
10002,1002,registration,Mal,Serenity Logistics,10001-1001,http://rjenks.github.io/Con-Badges
10003,1003,operations,Fry,Planet Express,10003-1003,http://rjenks.github.io/Con-Badges
The first badge above for Rose has a TYPE of "attendee" which causes Con-Badges to load a UTF8 encoded property file called "attendee.properties".
attendee.propertiesTEMPLATE=attendee
PICTURE=mountain
TYPE_LABEL=Attendee
This specifies that it should use the TEMPLATE called "attendee" which causes Con-Badges to load attendee.svg. It then combines the fields read from both the CSV and the properties file and uses those properties to do replacements in the SVG file, generate a PNG and possibly print the badge.
The software itself knows about several fields:
- TYPE
- BARCODE
- QRCODE
- PICTURE
- ID_BADGE
- ID_USER
- DESCRIPTION
You can also have as many user defined fields as you like. The field names are case-sensitive. TYPE is the only required field. However if you don’t provide other information it will generate a boring badge. These fields can match up with named elements in your SVG file. In your SVG editor (Inkscape or Adobe Illustrator) you will need to name the items to be replaced by the software.
You can have fields in your badge data that do not appear in your template. They will just be ignored. You can also have fields in your template that don’t exist in your badge data. In this case, any placeholder text you may have in your template will remain in the generated badge.
For example if you want to put someone’s BADGE_NAME at a location in the design:
- In the SVG editor, add a new text block
- Put some dummy text in the text block so that you have a reference to set the font and size.
- Name the text block BADGE_NAME
- Save the template
- Add the BADGE_NAME field to your badge data (CSV or web service)
Some of the special fields listed above have special behavior:
- BARCODE - Generates a Code 128 barcode from the badge data field. This can only contain letters and numbers as Code 128 barcodes cannot encode other characters. Add a dummy image into your SVG template and name it BARCODE. The size of the barcode generated will match the size of the placeholder. You MUST test your barcodes with the barcode scanner you intend to use to make sure the size can be read. Too small and the reader won’t be able to distinguish the line widths, too large and it won’t fit within the scanner range.
- QRCODE - Generates a QR Code from the badge data field. This could contain text or more typically a URL. As with BARCODE, the template should contain an image which will be replaced with the generated QR Code image. The placeholder should be square and you will need to test to make sure they are the correct size to be read.
- PICTURE - Replaces a template picture with a picture in the badgedata folder. Similar to the BARCODE and QRCODE fields except that the badge data field specifies the name of a PNG file (without extension) which should be replaced. For example, if your badge data has PICTURE=vendor, then the software will look for “vendor.png” in the badgedata folder for the replacement. To allow for per-user pictures, the system will also look to see if a file called ID_USER.png exists in the badgedata folder. If it does, it will use this image rather than the one specified by the field. This allows you to override the normal image with a personal image when needed.
All other fields are just a simple text replacement.
The TEMPLATE field specifies the name of the SVG template file without the .svg extension. Instead of being directly specified as a badge field it can also be specified in a badge type properties file. (See below)
The TYPE field specifies which SVG template to use. For example if you specify TYPE=staff, the software will look for a file called “staff.properties” in the badgedata folder. This file can contain any number of name=value lines which represent fields common to that type. The fields in this file will be added to the fields from the badge data (CSV or web), but will not overwrite existing fields. This file does not have to exist if all the fields you need are already in the badge data. This file is assumed to be in UTF8 text format which means that it can contain international characters.
ID_USER, ID_BADGE and DESCRIPTION are used by the GUI application to display what badge is being printed.
SVG Templates and Inkscape
Inkscape is an open source vector graphic program. It allows you to edit Scalable Vector Graphic (SVG) files. SVG files are not images although you can use them in similar ways. Raster images (PNG, JPG, BMP, etc...) are a series of pixels each having a color. Vector graphics are a collection of drawing operations. Instead of a series of pixel representing a circle, a vector graphic would contain instructions for drawing a circle of a specified radius with line and file colors. Vector graphics are especially useful when you need to scale a graphic to numerous sizes. Badge printers are often 300dpi, therefore to print a 4"x6" badge a full resolution you will need a 1200x1800 pixel raster image. Also because vector formats describe a graphic it means that Con-Badges can change the description before generating a raster image from it. For example it can replace text or images you have placed and formatted in the graphic.
In Inkscape when you are adding a text or image that should be replaced with Con-Badges you will need to edit the "Object Properties". In the dialog, change the "Id" and click the "Set" button. If you close the dialog without clicking the "Set" button the change won't be saved.

Fetching Badges from a Web Server
Con-Badges has the capability of fetching badges from a server. (This capability is disconnected at the moment, but should be resolved soon. I recently changed the application from a simple command line tool to having a user interface. In this processes I haven't finished adding the server connection back in. The code is all there if you're in a hurry.)
The application uses a HTTPS and token/key system to securely fetch badges. It uses a shared secret in the form of a per-client token which is never sent over the Internet. The system also includes a sequence number which should prevent replay attacks.
At startup Con-Badges will generate a unique Client ID and send this to the server. If the server has never seen this client it should generate and a new Token and keep a list of Client ID and their associated Tokens. The web server's administrator should then manually retrieve the token and put it in the Con-Badges configuration file.
Other than the initial handshake, every request from Con-Badges to the server will include an MD5 hash of the "CLIENTID-SEQUENCENUM-TOKEN" (The raw token is NEVER sent!). The server will have the same information and can generate and compare a locally generated MD5 hash with the hash received from Con-Badges.