ZPL or Zebra Programming Language is used within the Check In printer setup as of version 4.6.1. Humanforce Check In works with Zebra printers to create a variety of badges and wristbands.
Further information on the Check-In process within Humanforce Web can be found here.
ZPL documentation
The official ZPL documentation can be found here.
There are some examples and exercises for beginners on page 34.
Tips & tricks
If your organisation uses Check-In Printing, here are some tips to setting up what prints out.
Standard layout of a template
1 |
Every template starts with the ^XA command |
2 |
^CF0,32 – font and size of font. In this example: CF – indicates change in font 0 – font. See ZPL fonts 32 – size of font |
3 |
^FS – end of this field’s data |
4 |
^FWR – allows for the text to be rotated FW – affects only fields that follow it R – rotates the text 90 degrees |
5 |
^FO140,1200 where this sits on the wristband. In this example: 140 – horizontal position 1200 – vertical position Note wristbands work as the end coming out of the printer last as the “top”. If you look at the below example, Name, Role & Time all have a vertical position of 1200 indicating it is 1200 xx from the top of the wristband. |
6 |
^FD – allows you to type text required on the wristband @(xxx) – allows for the use of placeholders that pulls data from Humanforce |
7 |
BC – will put a barcode on the wristband. |
8 |
Every template ends with the ^XZ command |
Formatting font
The standard fonts are:
To change the font, you use the ^CF command:
e.g.
^CFA
^CFB
^CFD
…etc.
For scalable fonts you can add the size too. E.g.
^CF0,50
Formatting time
To change to AM/PM:
@RosterItem.DTRStart.ToString("h:mm tt")
24hr time:
@RosterItem.DTRStart.ToString("HH:mm") – 24hr time
Adding hardcoded text
Entering the text after the FD code will allow you to enter text which will appear on the wristband.
E.g.
^FDRole: @(Role.Name)^FS
Ensuring empty roster data fields do not return a blank value
If you are adding hardcoded text, but do not wish the hardcoded text to be displayed if the value after it is blank, you can use this trick. Just substitute the fields your organisation uses if not Roster Items and Areas.
At the top of your template, enter:
@{
string rostData1 = RosterItem != null ? (RosterItem.RostData1 != null ? "Briefing Point: " + RosterItem.RostData1.Name : "") : "";
string rostData2 = RosterItem != null ? (RosterItem.RostData2 != null ? "Briefing Point: " + RosterItem.RostData2.Name : "") : "";
string rostData3 = RosterItem != null ? (RosterItem.RostData3 != null ? "Briefing Point: " + RosterItem.RostData3.Name : "") : "";
string areaName = Area != null ? "Area: " + Area.Name : "";
string rosterTimes = RosterItem != null ? string.Format("{0:HH:mm} - {1:HH:mm}", RosterItem.DTRStart, RosterItem.DTREnd) : "(no roster)";
}
When entering the fields below, these will only appear if there is valid data in the system.
^FD @(rostData1)^FS
^FD @(rostData2)^FS
^FD @(rostData3)^FS
^FD @(areaName) ^FS
^FD @(rosterTimes)^FS
Example:
@{string rostData1 = RosterItem != null ? (RosterItem.RostData1 != null ? "Briefing Point: " + RosterItem.RostData1.Name : " ") : " ";
string rosterTimes = RosterItem != null ? string.Format("{0:HH:mm} - {1:HH:mm}", RosterItem.DTRStart, RosterItem.DTREnd) : "(no roster)";
}
^XA
^CF,30
^FO160,1000^FWR^FD@(Employee.Name)^FS
^FO135,1000^FWR^FD@(Location.Name)^FS
^FO135,1300^FWR^FD@(Department.Name)^FS
^FO100,1000^FWR^FD@(Role.Name)^FS
^FO70,1000^FWR^FD@(rosterTimes)^FS
^F030,1000^FWR^FD@(rostData1)^FS
^XZ
Adding age on wristbands
At the top of your template, enter before the ^XA command:
@{
int age = LocalDateTime.Year - Employee.DOB.Year;
age += Employee.DOB.AddYears(age) > LocalDateTime.Date ? -1 : 0;
}
If you already have a bracket section @{ … } at the top of your template then you can just add the lines of code into that section.
You’ll then have a new variable called “age” that you can refer to later in the template. E.g.
^FD@(age)^FS
Converting age to "Over 18" or "Under 18"
At the top of your template, enter this code:
@{
int age = LocalDateTime.Year - Employee.DOB.Year;
age += Employee.DOB.AddYears(age) > LocalDateTime.Date ? -1 : 0;
string ageCategory = age >= 18 ? "Over 18" : "Under 18";
}
The third line creates a variable with either “Over 18” or “Under 18” (over 18 includes exactly 18). Just change the text inside the double quotes to whatever you need.
You’ll then have a new variable called “ageCategory” that you can refer to later in the template. E.g.
^FD@(ageCategory)^FS
Adding "Happy Birthday" to an employee's wristband for their birthday
At the top of your template, enter:
@{
string message = Employee.DOB.Day == DateTime.Now.Day && Employee.DOB.Month == DateTime.Now.Month ? "HAPPY BIRTHDAY!!!" : "";
}
You’ll then have a new variable called “message” that you can refer to later in the template. E.g.
^FD@(message)^FS
Hints
1. Section your templates out for easy reading. Remember, it is ^FS that ends the previous field’s data.
2. Add text that won’t appear on the wristband but can be used to indicate what the section is about.
Entering ^FX will allow you to enter text which will not appear on the wristband.