c#通过txt文档利用打印机命令打印条码标签

来源:互联网 发布:mac删除下载的软件 编辑:程序博客网 时间:2024/05/20 02:21



直接以txt通过串口打印条码标签。包括Code39和DATAMATRIX。原理为把送给打印机的命令存入txt文

件。然后调用window自带命令copy整个文件到串口。打印机就会打印出设定的标签。具体打印机语言

ZPLII我也没有学习。我发现下面代码应该也不是用这个语言写的。下面这些打印机打标签命令模板是

之前供应商给的。具体我也看不懂。内容也只是替换一下变量test和test1就可以。打印机型号为

brady BP-PR 300 plus

  FileStream fs2 = new FileStream("D:\\Print.bat", FileMode.Create, FileAccess.Write);           //创建写入文件                             StreamWriter sw1 = new StreamWriter(fs2);            sw1.WriteLine("copy D:\\TestTxt.txt  LP>LPT1 " );            //开始写入值                            sw1.Close();            fs2.Close();                      FileStream fs1 = new FileStream("D:\\TestTxt.txt", FileMode.Create, FileAccess.Write);                //创建写入文件                                 StreamWriter sw = new StreamWriter(fs1);                sw.WriteLine("J");                sw.WriteLine("S L1;2,2,25,28,42");                sw.WriteLine("T 5,5,0,3,3;" + test);                sw.WriteLine("B 5,6,0,Code39,8,0.2;" + test1);                sw.WriteLine("T 5,17,0,3,3;" + test1);                sw.WriteLine("B 30,15,0,DATAMATRIX,0.3;" + test1);                sw.WriteLine("A 2");                //开始写入值                                sw.Close();                fs1.Close();                System.Diagnostics.Process.Start("D:\\Print.bat");

0 0