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