How to print small text on Zebra ZPL-EPL thermal printers by using ThermalLabel SDK f
How to print small text on Zebra ZPL-EPL thermal printers by using ThermalLabel SDK for .NET
Prerequisites
Neodynamic ThermalLabel SDK 4.0 for .NET
Microsoft .NET Framework 3.5 (or greater)
Microsoft Visual Studio 2008 / 2010
Microsoft Visual Studio 2008 / 2010 Express Editions (VB, C#, J#, and C++)
Any Zebra Thermal Printer supporting ZPL (Zebra Programming Language) or EPL (Eltron Programming Language)
Printing small text on thermal labels is a common request in some industries like Healthcare, Manufacturing, Retail, Security, Transportation, etc.
By printing small text, we mean text which font size is about 0.04 inch (about 1 millimiter) high. Printing such font size is not a problem at all if your thermal printer provides 300 or 600 dpi output printing resolution because you can use almost any TrueType font with the TextItem object and get a crisp and clear text after printing the label.
The problem arises if you are targeting or using a thermal printer which is 203 dpi. That resolution is commonly found on "Desktop thermal printers" although it is also found on "Midrange" and "High Performance" printers too. If your printer is 203 dpi, then getting a crisp and clear small text involves carefully selecting the TrueType font.
In ThermalLabel SDK we provide a solution to that scenario by using the so called "Bitmap or Pixel fonts". On any TextItem object, you enable these kind of fonts by setting up the IsBitmapFont property to True and specifying the correct size of the font using the Size and Unit properties.
We have made a couple of tests with some Bitmap/Pixel fonts available on the web. The following is the list of tested fonts and the minimum size for getting the smallest readable texts, mainly on 203 dpi printers:
Font Name: MonteCarlo (Normal & Bold)
TrueType Font Files: MonteCarloFixed12.ttf and MonteCarloFixed12-Bold.ttf (Info and download http://www.bok.net/MonteCarlo/ We tested the one contributed by Pete Gonzalez)
Minimun Size: 6pt
Font Name: Teachers Pet Sans Serif (Normal & Bold)
TrueType Font Files: TEACPSS_.ttf and TEACPSSB.ttf (Info and download http://www.orgdot.com/aliasfonts/)
Minimun Size: 3pt
The following code generates six TextItem objects featuring each font metioned above. Notice that IsBitmapFont property is set to True and the Unit and Size of the font are set up to the minimum size. The sample project is a Windows Forms app, which displays a preview of the generated thermal label at 203 dpi. This allows you to test how the TrueType font file will look like before printing.
Please follow up these steps:
Download all the fonts stated above to the C:\temp\test_fonts\ folder. For simplicity, we have packaged them into this file BitmapFontsForSmallTextPrinting.zip
IMPORTANT: Please review license terms for each font referring to their author sites.
Open Visual Studio 2008/2010 (or any Visual Studio Express 2008/2010 edition) and create a new Windows Forms project. Please ensure to select .NET 3.5 Framework or greater (Remember that ThermalLabel SDK does support .NET Client Profile too)
On the default Form1, please add a TextBox, a Button and a PictureBox. Select the PictureBox and set the SizeMode property to AutoSize
Add a reference to ThermalLabel SDK dll i.e. Neodynamic.SDK.ThermalLabel.dll
Double click on the Button and paste this code:
Visual Basic .NET
Dim dpi As Double = 203
Dim sampleText As String = Me.textBox1.Text
Dim tLabel As New ThermalLabel(UnitType.Inch, 3, 2)
tLabel.GapLength = 0.1
Dim txt1 As New TextItem(0.1, 0.1, 2.8, 0.25, "")
txt1.Font.Name = "Arial"
txt1.Font.Unit = FontUnit.Point
txt1.Font.Size = 6
txt1.Text = txt1.Font.Name + ": " + sampleText
Using pj As New PrintJob()
Using ms As New System.IO.MemoryStream()
pj.ExportToImage(tLabel, ms, new ImageSettings(ImageFormat.Tiff), dpi)
Me.pictureBox1.Image = Image.FromStream(ms)
End Using
End Using
Visual C# .NET
double dpi = 203;
string sampleText = this.textBox1.Text;
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 3, 2);
tLabel.GapLength = 0.1;
using (PrintJob pj = new PrintJob())
{
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
pj.ExportToImage(tLabel, ms, new ImageSettings(ImageFormat.Tiff), dpi);
Based on the output image preview of the label, you get that at 203 dpi, each font/size settings give the following text height:
Crisp.ttf (6pt), TEACPSS_.ttf (3pt) and TEACPSSB.ttf (3pt) at 203 dpi generate texts which whole height is about 0.044 inch (1.12 mm)
Both MonteCarloFixed12.ttf (6pt) and MonteCarloFixed12-Bold.ttf (6pt) at 203 dpi generate texts which whole height is about 0.034 inch (0.86 mm)
kharon.ttf (3pt) at 203 dpi generates a text which whole height is about 0.054 inch (1.37 mm)
Conclusions
If you need to print very small texts (about 0.04 inch or 1 mm high) on labels and your printer is 300 or 600 dpi, then almost any TrueType font at the right size do the job. But if your printer is 203 dpi, then use bitmap/pixel fonts instead.
Not all bitmap/pixel fonts are good for small text printing. Test them by using the code provided in this guide.
After the preview image output of a label featuring a given font is fine, please test it with your printer. In some cases, you will need to adjust the darkness settings on your printer for better text readability.
Bookmarks