C#怎么调用bartender软件

时间:2024-10-28 06:26:50

1、准备bartender软件的dll调用文件,根据自己安装的bartender软件的版本来准备,后续会因调用bartender软件的模板而失败。

C#怎么调用bartender软件

2、打开VS编程软件,按照自己的需求建立好winform界面。

C#怎么调用bartender软件

3、在项目管理引用中添加引用我们第一步准备好的bartender调用连接dll文件。

C#怎么调用bartender软件

4、用bartender软件编辑一个打印模板,这里有一个重点就是设置一个变量。这个变量名称会在源代码中调用到。

C#怎么调用bartender软件

5、编写源代码,我这里附上全部源代码供参考。using System;using System.Collections.Generic;using System.Compo荏鱿胫协nentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Runtime.InteropServices;namespace BlueTooth{ public partial class Form1 : Form { string PalletID1; public static BarTender.Application btapp1; public static BarTender.Format btFormat1; public Form1() { InitializeComponent(); } private void BasicSet1() { string str1 = System.Windows.Forms.Application.StartupPath + "\\bluet.btw"; btapp1 = new BarTender.ApplicationClass(); btFormat1 = btapp1.Formats.Open(str1, false, ""); } private void Form1_Load(object sender, EventArgs e) { BasicSet1(); } public void PrintLabel(string PalletID1) { btFormat1.SetNamedSubStringValue("TEST", PalletID1); btFormat1.IdenticalCopiesOfLabel = 1; btFormat1.PrintOut(false, false); } private void print(string label) { PalletID1 = textBox1.Text.Trim(); PrintLabel(PalletID1); } private void button1_Click(object sender, EventArgs e) { print(textBox1.Text.Trim()); } private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { print(textBox1.Text.Trim()); textBox1.SelectAll(); } } }}

C#怎么调用bartender软件

6、打印测试,实现了读取输入内容按设定模板打印的功能,问题解决,到此C#调用bartender软件完成。

C#怎么调用bartender软件
© 手抄报圈