C#調用CodeSoft打印條碼

引用:http://blog.csdn.net/JustLovePro/archive/2008/04/03/2246339.aspx

using LabelManager2;         //引入命名空间
private void btnPrint_Click(object sender, EventArgs e)
        {
            ApplicationClass lbl = new ApplicationClass();

            try
            {
                lbl.Documents.Open("D://test1.Lab", false);// 调用设计好的label文件
                Document doc = lbl.ActiveDocument;
                doc.Variables.FormVariables.Item("Var0").Value = txtMatno.Text.Trim(); //给参数传值
                doc.Variables.FormVariables.Item("Var1").Value = txtVersion.Text.Trim(); //给参数传值

                int Num = Convert.ToInt32(txtQty.Text);        //打印数量
                doc.PrintDocument(Num);                             //打印
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                lbl.Quit();                                         //退出
            }
        }

你可能感兴趣的:(C#調用CodeSoft打印條碼)