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

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

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

143411_3BZ5_2690029.jpg

详细步骤:

  • 下载最新版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窗体应用程序并测试,输出的打印效果如下图所示:

144048_cjjE_2690029.jpg

转载于:https://my.oschina.net/pengyi1992/blog/649201

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值