C#调用BarTender进行模板标签打印

先用Bartender设计出模板标签,里面的值使用变量形式,通过后台给标签变量赋值并打印标签

BarTender.Application btApp;
BarTender.Format btFormat;

private void Form1_FormLoad(object sender, FormLoadEventArgs e)

{        

//绑定模板btw

        btApp = new BarTender.Application();
            btFormat = new BarTender.Format();
            btFormat = btApp.Formats.Open(System.IO.Directory.GetCurrentDirectory() + "\\Test.btw");
            btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
            btFormat.PrintSetup.NumberSerializedLabels = 1;

}

private void button1_Click(object sender, EventArgs e)
        {
            //赋值、打印

             

            btFormat.SetNamedSubStringValue("label1", 值1);
            btFormat.SetNamedSubStringValue("label2", 值2);

            //... ...

            btFormat.PrintOut(true, false);

        }

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
        }

//获取默认打印机

//public static string GetDefaultPrinter()
        //{
            //System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();
            //return p.DefaultPageSettings.PrinterSettings.PrinterName;
        //}

你可能感兴趣的:(c#,开发语言)