彩票走势图

ThermalLabel SDK for .NET使用教程:打印多列标签

原创|使用教程|编辑:龚雪|2016-03-29 13:21:36.000|阅读 447 次

概述:大多数热敏打印机不提供打印多列标签的媒体滚动内置机制。为了突破这个限制,ThermalLabel SDK提供的out-of-the-box属性可以让您打印任意数量的每一列标签!

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

本次教程中我们将会使用到的多列标签布局如下图所示:

multicolumn label layout

详细步骤:

  • 下载最新版Neodynamic ThermalLabel SDK for .NET
  • 打开Visual Studio (v2005, or v2008, or 2010)并创建一个Windows窗体应用程序
  • 添加一个引用到Neodynamic.SDK.ThermalLabel.dll集合
  • 在窗体添加一个控制按钮,然后粘贴下列代码到该按钮的单击事件处理器中:

 

ZPL打印机


VB

'Define a ThermalLabel object and set unit to MM and label size
Dim tLabel As New ThermalLabel(UnitType.Mm, 50, 0)
'Set the number of labels per row
tLabel.LabelsPerRow = 2
'Set the horiz gap between labels
tLabel.LabelsHorizontalGapLength = 3
 
'Define a TextItem object
Dim txt As New TextItem(5, 5, "Decreasing 50")
'Set font...
txt.Font.CharHeight = 14
'set Counter...
txt.CounterStep = -1
 
'Define a BarcodeItem object
Dim bc As New BarcodeItem(5, 15, BarcodeSymbology.Code128, "ABC01")
'Set bars' width and height...
bc.BarWidth = 0.4
bc.BarHeight = 10
'set Counter...
bc.CounterStep = 1
bc.CounterUseLeadingZeros = True
 
'Add items to ThermalLabel object...
tLabel.Items.Add(txt)
tLabel.Items.Add(bc)
 
'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  GK420t"
'Set Copies to 10!!!
pj.Copies = 10
'Print ThermalLabel object...
pj.Print(tLabel)    

C#

//Define a ThermalLabel object and set unit to MM and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Mm, 50, 0);
//Set the number of labels per row
tLabel.LabelsPerRow = 2;
//Set the horiz gap between labels
tLabel.LabelsHorizontalGapLength = 3;
//Define a TextItem object
TextItem txt = new TextItem(5, 5, "Decreasing 50");
//Set font...
txt.Font.CharHeight = 14;
//set Counter...
txt.CounterStep = -1;
//Define a BarcodeItem object
BarcodeItem bc = new BarcodeItem(5, 15, BarcodeSymbology.Code128, "ABC01");
//Set bars' width and height...
bc.BarWidth = 0.4;
bc.BarHeight = 10;
//set Counter...
bc.CounterStep = 1;
bc.CounterUseLeadingZeros = true;
//Add items to ThermalLabel object...
tLabel.Items.Add(txt);
tLabel.Items.Add(bc);
//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  GK420t";
//Set Copies to 10!!!
pj.Copies = 10;
//Print ThermalLabel object...
pj.Print(tLabel);   

 

EPL打印机


VB

'Define a ThermalLabel object and set unit to MM and label size
Dim tLabel As New ThermalLabel(UnitType.Mm, 50, 30)
'Set the number of labels per row
tLabel.LabelsPerRow = 2
'Set the horiz gap between labels
tLabel.LabelsHorizontalGapLength = 3
'Set the vertical gap between labels
tLabel.GapLength = 3
 
'Define a TextItem object
Dim txt As New TextItem(5, 5, "Decreasing 50")
'Set font...
txt.Font.Name = "2"
txt.Font.CharHeight = 14
txt.Font.CharWidth = 8
 
'set Counter...
txt.CounterStep = -1
 
'Define a BarcodeItem object
Dim bc As New BarcodeItem(5, 15, BarcodeSymbology.Code128, "ABC01")
'Set bars' width and height...
bc.BarWidth = 0.4
bc.BarHeight = 10
'set Counter...
bc.CounterStep = 1
bc.CounterUseLeadingZeros = True
 
'Add items to ThermalLabel object...
tLabel.Items.Add(txt)
tLabel.Items.Add(bc)
 
'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.EPL
'Set Thermal Printer name 
pj.PrinterSettings.PrinterName = "Zebra  GK420t"
'Set Copies to 10!!!
pj.Copies = 10
'Print ThermalLabel object...
pj.Print(tLabel)    

C#

//Define a ThermalLabel object and set unit to MM and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Mm, 50, 0);
//Set the number of labels per row
tLabel.LabelsPerRow = 2;
//Set the horiz gap between labels
tLabel.LabelsHorizontalGapLength = 3;
//Set the vertical gap between labels
tLabel.GapLength = 3;
//Define a TextItem object
TextItem txt = new TextItem(5, 5, "Decreasing 50");
//Set font...
txt.Font.Name = "2";
txt.Font.CharHeight = 14;
txt.Font.CharWidth = 8;
 
//set Counter...
txt.CounterStep = -1;
//Define a BarcodeItem object
BarcodeItem bc = new BarcodeItem(5, 15, BarcodeSymbology.Code128, "ABC01");
//Set bars' width and height...
bc.BarWidth = 0.4;
bc.BarHeight = 10;
//set Counter...
bc.CounterStep = 1;
bc.CounterUseLeadingZeros = true;
//Add items to ThermalLabel object...
tLabel.Items.Add(txt);
tLabel.Items.Add(bc);
//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.EPL;
//Set Thermal Printer name 
pj.PrinterSettings.PrinterName = "Zebra  GK420t";
//Set Copies to 10!!!
pj.Copies = 10;
//Print ThermalLabel object...
pj.Print(tLabel);   
  • 运行示例Windows窗体应用程序并测试,输出的打印效果如下图所示:
multicolumn label layout

标签:条码生成条码打印

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@capbkgr.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP