資源簡介
核心代碼:
btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath @"\1.btw", false, "");
btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份數
btFormat.PrintSetup.NumberSerializedLabels = 1;//序列標簽數
btFormat.SetNamedSubStringValue("打印文本", txtMemo.Text.Trim());
btFormat.SetNamedSubStringValue("打印條碼", txtBarcode.Text.Trim());
btFormat.PrintOut(true, true);//第二個false設置打印時是否跳出打印屬性
btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); //退出時是否保存標簽
二、基本原理:
1、先設計好Btw模板
2、代碼調用模板去打印
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace BarTenderDemo
{
public partial class Form1 : Form
{
private BarTender.Application btAPP;
private BarTender.Format btFormat;
//SELECT MaterielId,ProductBigPackId,NetWeight,GrossWeight,num
//FROM Make_ProductBigPack mpb
//LEFT JOIN Make_TaskInfo mti ON mpb.TaskId=mti.TaskId
//WHERE ProductBigPackId=''
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
btAPP = new BarTender.Application();
}
private void btPrint_Click(object sender, EventArgs e)
{
try
{
btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath @"\1.btw", false, "");
btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份數
btFormat.PrintSetup.NumberSerializedLabels = 1;//序列標簽數
btFormat.SetNamedSubStringValue("打印文本", txtMemo.Text.Trim());
btFormat.SetNamedSubStringValue("打印條碼", txtBarcode.Text.Trim());
btFormat.PrintOut(true, true);//第二個false設置打印時是否跳出打印屬性
btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //退出時是否保存標簽
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
btAPP.Quit(BarTender.BtSaveOptions.btSaveChanges);//界面退出時同步退出bartender進程
}
}
}
btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath @"\1.btw", false, "");
btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份數
btFormat.PrintSetup.NumberSerializedLabels = 1;//序列標簽數
btFormat.SetNamedSubStringValue("打印文本", txtMemo.Text.Trim());
btFormat.SetNamedSubStringValue("打印條碼", txtBarcode.Text.Trim());
btFormat.PrintOut(true, true);//第二個false設置打印時是否跳出打印屬性
btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); //退出時是否保存標簽
二、基本原理:
1、先設計好Btw模板
2、代碼調用模板去打印
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace BarTenderDemo
{
public partial class Form1 : Form
{
private BarTender.Application btAPP;
private BarTender.Format btFormat;
//SELECT MaterielId,ProductBigPackId,NetWeight,GrossWeight,num
//FROM Make_ProductBigPack mpb
//LEFT JOIN Make_TaskInfo mti ON mpb.TaskId=mti.TaskId
//WHERE ProductBigPackId=''
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
btAPP = new BarTender.Application();
}
private void btPrint_Click(object sender, EventArgs e)
{
try
{
btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath @"\1.btw", false, "");
btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份數
btFormat.PrintSetup.NumberSerializedLabels = 1;//序列標簽數
btFormat.SetNamedSubStringValue("打印文本", txtMemo.Text.Trim());
btFormat.SetNamedSubStringValue("打印條碼", txtBarcode.Text.Trim());
btFormat.PrintOut(true, true);//第二個false設置打印時是否跳出打印屬性
btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //退出時是否保存標簽
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
btAPP.Quit(BarTender.BtSaveOptions.btSaveChanges);//界面退出時同步退出bartender進程
}
}
}
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
namespace?BarTenderDemo
{
????public?partial?class?Form1?:?Form
????{
????????private?BarTender.Application?btAPP;
????????private?BarTender.Format?btFormat;
????????//SELECT?MaterielIdProductBigPackIdNetWeightGrossWeightnum?
????????//FROM?Make_ProductBigPack?mpb
????????//LEFT?JOIN?Make_TaskInfo?mti?ON?mpb.TaskId=mti.TaskId
????????//WHERE?ProductBigPackId=‘‘
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????btAPP?=?new?BarTender.Application();
????????}
????????private?void?btPrint_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????btFormat?=?btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath+@“\1.btw“?false?““);
????????????????btFormat.PrintSetup.IdenticalCopiesOfLabel?=?1;//打印份數
????????????????btFormat.PrintSetup.NumberSerializedLabels?=?1;//序列標簽數
????????????????btFormat.SetNamedSubStringValue(“打印文本“?txtMemo.Text.Trim());
????????????????btFormat.SetNamedSubStringValue(“打印條碼“?txtBarcode.Text.Trim());
????????????????btFormat.PrintOut(true?true);//第二個false設置打印時是否跳出打印屬性
????????????????btFormat.Close(BarTender.BtSaveOptions.btSaveChanges);?//退出時是否保存標簽
????????????}
????????????catch(Exception?ex)
????????????{
????????????????MessageBox.Show(ex.Message);
????????????}
????????}
????????private?void?Form1_FormClosed(object?sender?FormClosedEventArgs?e)
????????{
????????????btAPP.Quit(BarTender.BtSaveOptions.btSaveChanges);//界面退出時同步退出bartender進程
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????10212??2017-03-30?11:10??BarTender二次開發示例\1.btw
?????文件??????10212??2018-03-07?17:55??BarTender二次開發示例\BarTenderDemo\1.btw
?????文件???????3793??2018-03-07?17:56??BarTender二次開發示例\BarTenderDemo\BarTenderDemo.csproj
?????文件??????10212??2018-03-07?17:55??BarTender二次開發示例\BarTenderDemo\bin\Debug\1.btw
?????文件???????9728??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\bin\Debug\BarTenderDemo.exe
?????文件??????22016??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\bin\Debug\BarTenderDemo.pdb
?????文件??????11592??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\bin\Debug\BarTenderDemo.vshost.exe
?????文件????????490??2013-06-18?20:24??BarTender二次開發示例\BarTenderDemo\bin\Debug\BarTenderDemo.vshost.exe.manifest
?????文件?????143360??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\bin\Debug\Interop.BarTender.dll
?????文件???????1897??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\Form1.cs
?????文件???????4295??2017-03-01?14:23??BarTender二次開發示例\BarTenderDemo\Form1.Designer.cs
?????文件???????5814??2017-03-01?14:23??BarTender二次開發示例\BarTenderDemo\Form1.resx
?????文件???????2326??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.csproj.FileListAbsolute.txt
?????文件????????847??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.csproj.GenerateResource.Cache
?????文件????????575??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.csproj.ResolveComReference.cache
?????文件???????9728??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.exe
?????文件????????180??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.Form1.resources
?????文件??????22016??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.pdb
?????文件????????180??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\BarTenderDemo.Properties.Resources.resources
?????文件?????143360??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\Interop.BarTender.dll
?????文件????????474??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo\Program.cs
?????文件???????1358??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo\Properties\AssemblyInfo.cs
?????文件???????2876??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo\Properties\Resources.Designer.cs
?????文件???????5612??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo\Properties\Resources.resx
?????文件???????1098??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo\Properties\Settings.Designer.cs
?????文件????????249??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo\Properties\Settings.settings
?????文件????????929??2017-02-28?11:27??BarTender二次開發示例\BarTenderDemo.sln
?????文件?????275536??2014-11-08?12:11??BarTender二次開發示例\Seagull.BarTender.Print.dll
?????文件????????709??2018-07-15?11:39??BarTender二次開發示例\說明.txt
????..AD...?????????0??2018-03-07?17:58??BarTender二次開發示例\BarTenderDemo\obj\Debug\Refactor
............此處省略11個文件信息
- 上一篇:企業OA管理系統
- 下一篇:微軟ocr MODI OCR調用識別,合成雙層pdf
評論
共有 條評論