1.确保安装的bartender是正版或者破解版;预览版无法打印;
安装参考网站:http://www.ddooo.com/softdown/175384.htm
2.打印功能,代码如下
如果出现路径错误,将btw文件放到 \bin\Debug目录中,Api放入\bin\Debug\net5.0
BarTender.Application btapp;
BarTender.Format btformat;
//文件路径
var path = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + "Demo.btw";
btapp = new BarTender.Application();
//找到打印模板
btformat = btapp.Formats.Open(path, false, "");
//指定打印机
btformat.Printer = "TSC TTP-344M Pro";
//设置同序列的打印份数
btformat.PrintSetup.IdenticalCopiesOfLabel = 1;
//设置打印序列数
btformat.PrintSetup.NumberSerializedLabels = 3;
btformat.SetNamedSubStringValue("Code", XXX);
btformat.SetNamedSubStringValue("Date", DateTime.Now.ToString("yyyy-MM-dd HH:ss"));
btformat.SetNamedSubStringValue("COName", XXX);
//设置打印机属性;第二个false设置是否跳出打印属性
btformat.PrintOut(true, false);
btformat.Close(BarTender.BtSaveOptions.btSaveChanges);