1. Realize BarTender printing.
①: The first step: First, reference the Interop.BarTender.dll file
②: The second step, paste the code directly
public partial class Form1: Form
{
private BarTender.Application btApp; //Bartender application examples
private BarTender.Format btFormat; //Bartender style
public FormFT()
{
InitializeComponent();
}
//Label printing
private void button_Click(object sender, EventArgs e)
{
btApp = new BarTender.Application();
try
{
btFormat = btApp.Formats.Open(@"D:\tag .btw", false, ""); //label address
}
catch (Exception)
{
MessageBox.Show(@"The D:\ tag is not found!< /span>", " Tip");
return;
}
btFormat.PrintSetup.NumberSerializedLabels = 1; // Set the number of copies to be printed// Production model
btFormat.SetNamedSubStringValue("product_version", txt_1.Text);
btFormat.PrintOut(true, false); < span style="color: #008000;">//The second parameter sets whether to jump out of the print attributes;
btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //Whether to save tags when exiting
btApp.Quit(BarTender.BtSaveOptions.btSaveChanges);// Exit the bartender synchronously when exiting Process
}
}
③: The above code should pay attention to a few places
1. Put the label in A place on the computer (address above: D:\label.btw)
2, txt_1.Text is the content of the text box named txt_1 on winfrom.
3. product_version is the text name in BarTender. (If there is no such name on the template, an error will be reported)
p>
4. BarTender software must be installed on the computer that prints the template (that is, only one template is not enough, but the software must be installed), otherwise the program will report an error.
2. The BarTender software is attached. The download address is not provided, so you can find it yourself.
The look of the template
the appearance of the software
public partial class Form1: Form
{
private BarTender.Application btApp; //Bartender application examples
private BarTender.Format btFormat; //Bartender style
public FormFT()
{
InitializeComponent();
}
//Label printing
private void button_Click(object sender, EventArgs e)
{
btApp = new BarTender.Application();
try
{
btFormat = btApp.Formats.Open(@"D:\tag .btw", false, ""); //label address
}
catch (Exception)
{
MessageBox.Show(@"The D:\ tag is not found!< /span>", " Tip");
return;
}
btFormat.PrintSetup.NumberSerializedLabels = 1; // Set the number of copies to be printed// Production model
btFormat.SetNamedSubStringValue("product_version", txt_1.Text);
btFormat.PrintOut(true, false); < span style="color: #008000;">//The second parameter sets whether to jump out of the print attributes;
btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //Whether to save tags when exiting
btApp.Quit(BarTender.BtSaveOptions.btSaveChanges);// Exit the bartender synchronously when exiting Process
}
}