All Zebra (ZPL-based and EPL-based) thermal barcode printers
provide built-in support for printing Code 39 barcodes as well as
other barcode standards.
Code 39 barcode is suitable for encoding general purpose alphanumeric data. By
default, Code 39 can encode uppercase letters (A through Z), digits (0 through
9) and a handful of special characters like the *, -, $, %, (Space), ., /, and
+. However, it is possible to encode all 128 ASCII characters as well by using
the "extended version" of Code 39. It is important to note that the *
(asterisk) found on Code 39 barcodes is not a true encodable character, but is
the start and stop "symbol". In this guide you will learn how to print full
ASCII Code 39 barcodes with Zebra ZPL-EPL printers by using ThermalLabel SDK
for .NET
IMPORTANT: To test the sample code you must have installed a Zebra
ZPL-based or EPL-based thermal printer.
If the Human Readable Text is not correctly printed in ZPL-based printers...
Sadly, some Zebra ZPL Firmware versions do not support printing full ASCII
human readable text when using Code 39 i.e. for example, based on the code
above your Zebra printer will print
+L+O+W+E+R123 instead of
lower123
in the human readable text. To solve this issue you will have to not display
human readable text on the barcode (by using DisplayCode property of
BarcodeItem object) and replace it by using a TextItem. In addition, for
centering human readable text below the barcode bars, you could use a
TableShapeItem. The following code uses a table with 1 column and 2 rows trying
to work-around the firmware issue.
Visual Basic .NET
'Define a ThermalLabel object and set unit to cm and label size
Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 0)
'Define a TableShapeItem object
Dim table As New TableShapeItem(1, 1, 8, 3, 1, 2)
'Set row's height...
table.Rows(0).Height = 2
table.Rows(1).Height = 1
'hide cell borders...
table.StrokeThickness = 0
'set cell spacing...
table.CellSpacing = 0.1
'set barcode in cell 0,0
table.Cells(0, 0).Content = CellContent.Barcode
table.Cells(0, 0).ContentBarcode.Symbology = BarcodeSymbology.Code39
table.Cells(0, 0).ContentBarcode.Code = "lower123"
table.Cells(0, 0).ContentBarcode.BarWidth = 0.04
table.Cells(0, 0).ContentBarcode.BarHeight = 2
table.Cells(0, 0).ContentBarcode.AddChecksum = false
table.Cells(0, 0).ContentBarcode.DisplayCode = false
'set barcode in cell 1,0
table.Cells(1, 0).Content = CellContent.Text
table.Cells(1, 0).ContentText.Text = "lower123"
table.Cells(1, 0).ContentText.Font.CharHeight = 12
table.Cells(1, 0).ContentAlignment = CellContentAlignment.Center
'Add items to ThermalLabel object...
tLabel.Items.Add(table)
'Create a PrintJob object
Dim pj As New PrintJob()
'Thermal Printer is connected through USB
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB
'Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203
'Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
'Set Thermal Printer name
pj.PrinterSettings.PrinterName = "Zebra TLP2844-Z"
'Print ThermalLabel object...
pj.Print(tLabel)
Visual C# .NET
//Define a ThermalLabel object and set unit to cm and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Cm, 10, 0);
//Define a TableShapeItem object
TableShapeItem table = new TableShapeItem(1, 1, 8, 3, 1, 2);
//Set row's height...
table.Rows[0].Height = 2;
table.Rows[1].Height = 1;
//hide cell borders...
table.StrokeThickness = 0;
//set cell spacing...
table.CellSpacing = 0.1;
//set barcode in cell 0,0
table.Cells[0, 0].Content = CellContent.Barcode;
table.Cells[0, 0].ContentBarcode.Symbology = BarcodeSymbology.Code39;
table.Cells[0, 0].ContentBarcode.Code = "lower123";
table.Cells[0, 0].ContentBarcode.BarWidth = 0.04;
table.Cells[0, 0].ContentBarcode.BarHeight = 2;
table.Cells[0, 0].ContentBarcode.AddChecksum = false;
table.Cells[0, 0].ContentBarcode.DisplayCode = false;
//set barcode in cell 1,0
table.Cells[1, 0].Content = CellContent.Text;
table.Cells[1, 0].ContentText.Text = "lower123";
table.Cells[1, 0].ContentText.Font.CharHeight = 12;
table.Cells[1, 0].ContentAlignment = CellContentAlignment.Center;
//Add items to ThermalLabel object...
tLabel.Items.Add(table);
//Create a PrintJob object
PrintJob pj = new PrintJob();
//Thermal Printer is connected through USB
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB;
//Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203;
//Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
//Set Thermal Printer name
pj.PrinterSettings.PrinterName = "Zebra TLP2844-Z";
//Print ThermalLabel object...
pj.Print(tLabel);
If you need more information or assistance, please contact our
.