惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
博客园_首页
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
B
Blog
D
DataBreaches.Net
腾讯CDC
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
月光博客
月光博客
V
V2EX
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
The Cloudflare Blog
博客园 - 叶小钗
Y
Y Combinator Blog

博客园 - 白沙河

axure 用中继器实现下拉多选框 excel 常用全局变量 win10 x64 python3.6 pycharm 安装statsmodels Oracle 10进制转36进制 概念数据模型设计与逻辑数据模型设计、物理数据模型设计的关系 does not support ASP.NET compatibility 错误 Oracle日志文件管理与查看 oradmin相关用法 Oracle Standby Database 实现方案 win2008 64位 + oracle11G 64位 IIS7.5 配置WEBSERVICE VISIO 2007 修改形状默认字体 自定义模具 c# 解决IIS写Excel的权限问题 EXTJS gridpanel 动态设置表头 vs2008 连接 vss2005 出现 analyze utility 错误的解决方法 WPF CANVAS 内形状的margin为负值时定位不正确的问题 韶关旅游攻略 extjs 文件上传对话框显示后,页面出现空白的问题 IE8不能上网的问题 一些事件的评论
c# 调用zebra打印指令 打印到USB端口
白沙河 · 2014-05-06 · via 博客园 - 白沙河

c# 调用zebra打印机指令打印条码,如果直接打印到lpt1端口的打印机,通过copy指令没有问题,

但如果ZEBRA打印机是通过USB连接,打印机端口为usb001,则程序不能直接拷贝到usb001端口。

必须先共享本机的usb端口打印机,再将共享后的打印机名连接为LPT端口打印机,则可以成功打印。

from:

http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/how-do-i-print-a-file-to-my-usb-printer-in-windows/cc20646f-686c-4b45-9495-1d833b0f5fda

一下是设置步骤:

Set the printer to Shared, and make note of the name that you give it.
Then go to Start | Run, and enter the line
NET USE LPT1 \\name of your computer\shared name of printer
You will now be able to issue the command
COPY /b \path\filename.prn LPT1:

/b 参数不用也可以。

c#代码

private void button1_Click(object sender, EventArgs e)
        {
            string wo = "TEST002";
            string tmpFile = "d:\\123.txt";
            string prtName = @"\\WIN7-20140313GI\test";
            StringBuilder str = new StringBuilder();

            str.Append("^XA \r\n"); //打印命令开始
            str.Append("^LL 600^FS \r\n");//定义标签长度 105SL 300 DPI (1mm 12pt) 50mm*12
            str.Append("^PW 1200 \r\n");  //定义标签寬度 100mm*12
            str.Append("^FO40,60^A@N,55,35,E:ARIALR.FNT^FDWO:" + wo + "^FS \r\n");//定义坐标,字体
            str.Append("^FO40,150^BY4,4^BCN,100,N,N,N,A^FR^FD" + wo + "^FS \r\n");//128码
            str.Append("^XZ");//结束打印



            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(tmpFile))
            {
                sw.Write(str.ToString());            
            }

            System.IO.File.Copy(tmpFile, prtName, true);
        }