从Zebra打印机读取状态 [英] Reading status from Zebra Printer

查看:1240
本文介绍了从Zebra打印机读取状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,我们需要使用Zebra打印机来打印条形码标签. 我们正在使用C#,并且在打印方面做得很好,将原始ZPL字符串发送到打印机(使用winspool.drv).

I'm working on a project where we need to use a Zebra Printer for barcode labels. We're using C#, and we're doing OK on the printing side of things, sending raw ZPL strings to the printer (using winspool.drv).

但是,我们还需要从打印机中读取内容,那里没有运气.

However, we also need to read from the printer, and no luck there.

我们需要从打印机获取状态,这是ZPL命令〜HS"的输出,因此我们可以知道内存中有多少标签等待打印. winspool.drv中的EnumJobs()仅在Windows假脱机上有作业,一旦将它们发送到打印机,它们就会从该列表中消失.但这并不意味着标签已经打印,因为打印机具有剥离传感器并且一次只能打印一个标签,并且我们显然有兴趣向打印机发送一批标签.

We need to get the status from the printer, which is the output to the ZPL command "~HS", so we can tell how many labels are in memory waiting to be printed. The EnumJobs() from winspool.drv only has jobs on the windows spool, and once they're sent to the printer, they're gone from that list. But that doesn't mean the label has been printed, since the printer has a peel sensor and only prints one label at a time, and we're obviously interested in sending batches of labels to the printer.

我已经尝试过类似的操作(使用winspool.drv调用):

I've tried something like (using the winspool.drv calls):

OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero);
WritePrinter(hPrinter, pBytes, dwCount, out dwWritten); // send the string "~HS"
ReadPrinter(hPrinter, data, buff, out pcRead);

但是ReadPrinter调用没有任何帮助.我什至不知道这是否是正确的方法.

But I get nothing on the ReadPrinter call. I don't even know if this is the right way of going at it.

外面有人解决过吗?

谢谢.

推荐答案

我遇到了同样的问题.您已经在此主题上进行任何管理了吗?

I'm facing the same problem. Did you already manage anything on this subject?

斧头佩雷斯·帕拉·卡斯特罗,这就是我的做法:

Ax Perez Parra Castro, this is how I did it:

-从此处获取RawPrinterHelper类 http://support.microsoft.com/kb/322091

-get the RawPrinterHelper class from here http://support.microsoft.com/kb/322091

-我的打印机(斑马2030)不支持ZPL,据我所知,唯一的方法是向其中发送unicode

-my printer (zebra 2030) doesn't support ZPL, so as far as I know the only way is to send unicode to it

-我列出了我需要的字符列表

-I made a list of characters I need e.g.

string enq = Convert.ToChar(5).ToString();
string esc = Convert.ToChar(27).ToString();
string nul = Convert.ToChar(0).ToString();
string rs = Convert.ToChar(30).ToString();
string lf = Convert.ToChar(10).ToString();
string cr = Convert.ToChar(13).ToString();

(从en.wikipedia.org/wiki/ASCII中获取这些int值)

(get those int values from en.wikipedia.org/wiki/ASCII)

-编写命令-例如sb.Append(esc + enq + Convert.ToChar(7).ToString());(从打印机手册中,命令< ESC>< ENQ>< 7>应该获得固件版本)

-compose the command - e.g. sb.Append(esc + enq + Convert.ToChar(7).ToString()); (from the printer manual, the command < ESC>< ENQ><7> should get the firmware version)

-发送命令RawPrinterHelper.SendStringToPrinter(printerName, sb.ToString());(在我的情况下,printerName是"Zebra TTP 2030")

-send the command RawPrinterHelper.SendStringToPrinter(printerName, sb.ToString()); (printerName in my case is "Zebra TTP 2030")

这篇关于从Zebra打印机读取状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆