How to print small text on Zebra ZPL-EPL thermal printers by using ThermalLabel SDK for .NET
Product ThermalLabel SDK for .NET Published 07/08/2011 Updated 04/18/2018
Requirements
Neodynamic ThermalLabel SDK 8.0+
Microsoft .NET Framework 4.6.1+
Microsoft Visual Studio 2017+
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.
For Zebra ZPL printers, we suggest you to use built-in ZPL Font 0 which support small sizes out of the box.
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: Crisp
TrueType Font File: Crisp.ttf (Info and download http://www.proggyfonts.com/index.php?menu=download)
Minimun Size: 6pt - Font Name: Kharon
TrueType Font File: kharon.ttf (Info and download http://www.orgdot.com/aliasfonts/)
Minimun Size: 3pt - 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 and create a new Windows Forms project. Please ensure to select .NET 4.6.1 Framework or greater
- 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 Neodynamic.SDK.ThermalLabel.dll
- Double click on the Button and paste this code:
VB
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 Dim txt2 As New TextItem(0.1, 0.35, 2.8, 0.25, "") txt2.Font.CustomFontFile = "C:\temp\test_fonts\crisp.ttf" txt2.Font.CustomFontFileFamilyName = "Crisp" txt2.Font.IsBitmapFont = True txt2.Font.Unit = FontUnit.Point txt2.Font.Size = 6 txt2.Text = txt2.Font.CustomFontFileFamilyName + ": " + sampleText Dim txt3 As New TextItem(0.1, 0.6, 2.8, 0.25, "") txt3.Font.CustomFontFile = "C:\temp\test_fonts\MonteCarloFixed12.ttf" txt3.Font.CustomFontFileFamilyName = "MonteCarlo Fixed 12" txt3.Font.IsBitmapFont = True txt3.Font.Unit = FontUnit.Point txt3.Font.Size = 6 txt3.Text = txt3.Font.CustomFontFileFamilyName + ": " + sampleText Dim txt3b As New TextItem(0.1, 0.85, 2.8, 0.25, "") txt3b.Font.CustomFontFile = "C:\temp\test_fonts\MonteCarloFixed12-Bold.ttf" txt3b.Font.CustomFontFileFamilyName = "MonteCarlo Fixed 12" txt3b.Font.IsBitmapFont = True txt3b.Font.Unit = FontUnit.Point txt3b.Font.Size = 6 txt3b.Text = txt3b.Font.CustomFontFileFamilyName + ": " + sampleText Dim txt4 As New TextItem(0.1, 1.1, 2.8, 0.25, "") txt4.Font.CustomFontFile = "C:\temp\test_fonts\TEACPSS_.ttf" txt4.Font.CustomFontFileFamilyName = "Teachers Pet Sans Serif" txt4.Font.IsBitmapFont = True txt4.Font.Unit = FontUnit.Point txt4.Font.Size = 3 txt4.Text = txt4.Font.CustomFontFileFamilyName + ": " + sampleText Dim txt4b As New TextItem(0.1, 1.35, 2.8, 0.25, "") txt4b.Font.CustomFontFile = "C:\temp\test_fonts\TEACPSSB.ttf" txt4b.Font.CustomFontFileFamilyName = "Teachers Pet Sans Serif Bold" txt4b.Font.IsBitmapFont = True txt4b.Font.Unit = FontUnit.Point txt4b.Font.Size = 3 txt4b.Text = txt4b.Font.CustomFontFileFamilyName + ": " + sampleText Dim txt5 As New TextItem(0.1, 1.6, 2.8, 0.25, "") txt5.Font.CustomFontFile = "C:\temp\test_fonts\kharon.ttf" txt5.Font.CustomFontFileFamilyName = "Kharon4a_v01" txt5.Font.IsBitmapFont = True txt5.Font.Unit = FontUnit.Point txt5.Font.Size = 3 txt5.Text = txt5.Font.CustomFontFileFamilyName + ": " + sampleText tLabel.Items.Add(txt1) tLabel.Items.Add(txt2) tLabel.Items.Add(txt3) tLabel.Items.Add(txt3b) tLabel.Items.Add(txt4) tLabel.Items.Add(txt4b) tLabel.Items.Add(txt5) Using pj As New PrintJob() Using ms As New System.IO.MemoryStream() pj.ExportToImage(tLabel, ms, new ImageSettings(ImageFormat.Png), dpi) Me.pictureBox1.Image = Image.FromStream(ms) End Using End UsingC#
double dpi = 203; string sampleText = this.textBox1.Text; ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 3, 2); tLabel.GapLength = 0.1; TextItem txt1 = 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; TextItem txt2 = new TextItem(0.1, 0.35, 2.8, 0.25, ""); txt2.Font.CustomFontFile = @"C:\temp\test_fonts\crisp.ttf"; txt2.Font.CustomFontFileFamilyName = "Crisp"; txt2.Font.IsBitmapFont = true; txt2.Font.Unit = FontUnit.Point; txt2.Font.Size = 6; txt2.Text = txt2.Font.CustomFontFileFamilyName + ": " + sampleText; TextItem txt3 = new TextItem(0.1, 0.6, 2.8, 0.25, ""); txt3.Font.CustomFontFile = @"C:\temp\test_fonts\MonteCarloFixed12.ttf"; txt3.Font.CustomFontFileFamilyName = "MonteCarlo Fixed 12"; txt3.Font.IsBitmapFont = true; txt3.Font.Unit = FontUnit.Point; txt3.Font.Size = 6; txt3.Text = txt3.Font.CustomFontFileFamilyName + ": " + sampleText; TextItem txt3b = new TextItem(0.1, 0.85, 2.8, 0.25, ""); txt3b.Font.CustomFontFile = @"C:\temp\test_fonts\MonteCarloFixed12-Bold.ttf"; txt3b.Font.CustomFontFileFamilyName = "MonteCarlo Fixed 12"; txt3b.Font.IsBitmapFont = true; txt3b.Font.Unit = FontUnit.Point; txt3b.Font.Size = 6; txt3b.Text = txt3b.Font.CustomFontFileFamilyName + ": " + sampleText; TextItem txt4 = new TextItem(0.1, 1.1, 2.8, 0.25, ""); txt4.Font.CustomFontFile = @"C:\temp\test_fonts\TEACPSS_.ttf"; txt4.Font.CustomFontFileFamilyName = "Teachers Pet Sans Serif"; txt4.Font.IsBitmapFont = true; txt4.Font.Unit = FontUnit.Point; txt4.Font.Size = 3; txt4.Text = txt4.Font.CustomFontFileFamilyName + ": " + sampleText; TextItem txt4b = new TextItem(0.1, 1.35, 2.8, 0.25, ""); txt4b.Font.CustomFontFile = @"C:\temp\test_fonts\TEACPSSB.ttf"; txt4b.Font.CustomFontFileFamilyName = "Teachers Pet Sans Serif Bold"; txt4b.Font.IsBitmapFont = true; txt4b.Font.Unit = FontUnit.Point; txt4b.Font.Size = 3; txt4b.Text = txt4b.Font.CustomFontFileFamilyName + ": " + sampleText; TextItem txt5 = new TextItem(0.1, 1.6, 2.8, 0.25, ""); txt5.Font.CustomFontFile = @"C:\temp\test_fonts\kharon.ttf"; txt5.Font.CustomFontFileFamilyName = "Kharon4a_v01"; txt5.Font.IsBitmapFont = true; txt5.Font.Unit = FontUnit.Point; txt5.Font.Size = 3; txt5.Text = txt5.Font.CustomFontFileFamilyName + ": " + sampleText; tLabel.Items.Add(txt1); tLabel.Items.Add(txt2); tLabel.Items.Add(txt3); tLabel.Items.Add(txt3b); tLabel.Items.Add(txt4); tLabel.Items.Add(txt4b); tLabel.Items.Add(txt5); using (PrintJob pj = new PrintJob()) { using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { pj.ExportToImage(tLabel, ms, new ImageSettings(ImageFormat.Png), dpi); this.pictureBox1.Image = Image.FromStream(ms); } } - Run the app and enter some text on the TextBox. Click on the button and you will get preview of all font settings.
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
- For Zebra ZPL printers, we suggest you to use built-in ZPL Font 0 which support small sizes out of the box.
- 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.
Need help? Contact Support
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.