受欢迎的博客标签

BarTender 集成模式之三:ActiveX COM模式:C#调用BarTender ActiveX Com(BarTender.Application引用)打印条码

Published

https://blog.csdn.net/z_344791576/article/details/46328443

1.设计标签模板

2.C#利用BarTender's ActiveX Automation interface (BartTender ActiveX Com组件)打印标签

C#中调用需要引用“BarTender”,如图,至于后面的9.40是你安装的“BarTender”的版本。

To reference the BarTender API

Open the Project menu, and select Add Reference.
Click on the COM tab.
Scroll down and click on the BarTender reference so that it is highlighted.
Click OK.

other

Using ActiveX Automation with BarTender requires the Automation Edition of BarTender or better.

G:\BarTenderLabelPrinter\WindowsFormsBarTenderLabelPrinter\obj\Debug\Interop.BarTender.dll

 

try
{
//调用Bartender
btApp = new BarTender.Application();
//获取打印模板,指定打印机
btFormat = btApp.Formats.Open(Application.StartupPath + “\1DbarCode.btw”, false, “”);
// 同样标签的份数
btFormat.PrintSetup.IdenticalCopiesOfLabel = pageCount;
// 序列标签数
btFormat.PrintSetup.NumberSerializedLabels = 1;
//设置参数
btFormat.SetNamedSubStringValue(“1Dbarcode”, barcode);
//打印开始 第2个参数是 是否显示打印机属性的。可以设置打印机路径
btFormat.PrintOut(false, false);
//关闭摸板文件,并且关闭文件流
btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
//打印完毕
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
return true;
}
catch (Exception e)
{
return false;
throw e;
}