1.安装BarTender10.01软件(附**版下载地址+https://pan.baidu.com/s/1dxmpbodVwpbOcefIYQCKBA)
2.引用COM库:
3.制作BarTender模板:
4.填代码:简单实例如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Print_Barcode_Code
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
BarTender.Application btapp;
BarTender.Format btformat;
private void button1_Click(object sender, EventArgs e)
{
btapp = new BarTender.Application();
btformat = btapp.Formats.Open(@"C:\MasterCarton.btw", false, "");
btformat.PrintSetup.NumberSerializedLabels = 1;//设置打印份数
btformat.SetNamedSubStringValue("P_N", "9801A1FE");//C/N
btformat.SetNamedSubStringValue("C_N", "C8M20181007000");//P/N
btformat.SetNamedSubStringValue("SN_1", "219801A1FE8189M00002");//SN1
btformat.SetNamedSubStringValue("SN_2", "219801A1FE8189M00003");//SN2
btformat.SetNamedSubStringValue("SN_3", "219801A1FE8189M00004");//SN3
btformat.SetNamedSubStringValue("SN_4", "219801A1FE8189M00005");//SN4
btformat.SetNamedSubStringValue("SN_5", "219801A1FE8189M00006");//SN5
btformat.SetNamedSubStringValue("SN_6", "219801A1FE8189M00007");//SN6
btformat.SetNamedSubStringValue("SN_7", "219801A1FE8189M00008");//SN7
btformat.SetNamedSubStringValue("SN_8", "219801A1FE8189M00009");//SN8
btformat.SetNamedSubStringValue("SN_9", "219801A1FE8189M0000C");//SN9
btformat.SetNamedSubStringValue("SN_10", "219801A1FE8189M0000D");//SN10
btformat.SetNamedSubStringValue("SN_11", "219801A1FE8189M0000F");//SN11
btformat.SetNamedSubStringValue("SN_12", "219801A1FE8189M0000G");//SN12
btformat.SetNamedSubStringValue("SN_13", "219801A1FE8189M0000H");//SN13
btformat.SetNamedSubStringValue("SN_14", "219801A1FE8189M0000K");//SN14
btformat.SetNamedSubStringValue("SN_15", "219801A1FE8189M0000L");//SN15
btformat.SetNamedSubStringValue("SN_16", "219801A1FE8189M0000M");//SN16
btformat.SetNamedSubStringValue("SN_17", "219801A1FE8189M0000N");//SN17
btformat.SetNamedSubStringValue("SN_18", "219801A1FE8189M0000P");//SN18
btformat.SetNamedSubStringValue("SN_19", "219801A1FE8189M0000Q");//SN19
btformat.SetNamedSubStringValue("SN_20", "219801A1FE8189M0000R");//SN120
String The_Combined_Code = "219801A1FE8189M00002\n" + "219801A1FE8189M00003\n" +
"219801A1FE8189M00004\n" + "219801A1FE8189M00005\n" +
"219801A1FE8189M00006\n" + "219801A1FE8189M00007\n" +
"219801A1FE8189M00008\n" + "219801A1FE8189M00009\n" +
"219801A1FE8189M0000C\n" + "219801A1FE8189M0000D\n" +
"219801A1FE8189M0000E\n" + "219801A1FE8189M0000F\n" +
"219801A1FE8189M0000G\n" + "219801A1FE8189M0000H\n" +
"219801A1FE8189M0000K\n" + "219801A1FE8189M0000L\n" +
"219801A1FE8189M0000M\n" + "219801A1FE8189M0000N\n" +
"219801A1FE8189M0000P\n" + "219801A1FE8189M0000Q\n" +
"219801A1FE8189M0000R\n";
btformat.SetNamedSubStringValue("SN_21", The_Combined_Code);//SN121
btformat.PrintOut(true, true);//第二个参数设置是否跳出打印属性
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
btapp.Quit(BarTender.BtSaveOptions.btSaveChanges);//退出时同退退出BarTender进程
}
}
}
|
请发表评论