c#调用BT条码软件打印标签


1、首先,电脑要安装Bartender软件。
在C#代码中添加引用,添加COM组件 选择本地浏览,选择Bartender安装目录下的SDK文件夹(C:\Program Files\Seagull\BarTender Suite\SDK\Assemblies)

 

然后添加引用Bartender:

 

 

 

 

2.代码中引入
    using Seagull.BarTender.Print;

3.代码部分
namespace WinFormTest
{
public partial class Form1 : Form
{

BarTender.Application btapp;
BarTender.Format btformat;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
try
{
btapp = new BarTender.Application();
btformat = btapp.Formats.Open(@"D:\Users\amaris.ma\Desktop\opp\opp\G05_TRAY2.btw", false, "");
}
catch (Exception ex)
{
MessageBox.Show("加载BarTender实例失败!");
}
}

private void button1_Click(object sender, EventArgs e)
{
btformat.PrintSetup.NumberSerializedLabels = 1; //设置打印份数
btformat.SetNamedSubStringValue("SN", "123233");
btformat.PrintOut(true, false); //第二个参数设置是否跳出打印属性;
MessageBox.Show("oook");  //[HKXEDKXEKIXEKD]
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
btformat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); //退出时是否保存标签
btapp.Quit(BarTender.BtSaveOptions.btSaveChanges);//退出时同退退出BarTender进程
}


}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM