Brother 打印机 Esc/P [英] Brother printer Esc/P

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

问题描述

我想打印产品列表的定价标签.当价格发生变化时,我无法使用 csv,并且正在通过内部应用程序执行此操作.如何将数据数组发送到打印机.我一次可以打印一个标签,但是这很慢.通过 P Template 软件,它的打印速度非常快.任何帮助将不胜感激.

I am wanting to print pricing labels for a list of products. I cannot use the csv as the prices change and am doing this through an in house application. How do I send like an array of data to the printer. I can print one label at a time, however this is slow. Through the P Template software it prints really quick. Any help would be much appreciated.

我正在以十六进制向打印机发送命令,它们工作正常.可以使用 Esc/P 模式和 P 模板模式进行打印.P 模板模式更好,因为可以在打印机上设置和存储布局,然后我需要做的就是发送对象数据.

I am sending the commands to the printer in Hex and they work ok. Can print with Esc/P mode and with P Template mode. P Template mode is better as the layout can be set and stored on the printer, then all I need to do is send the object data.

关于如何发送各种类型的数组的任何帮助将不胜感激.

Any help on how to send an array of sorts would be much appreciated.

推荐答案

我们正在使用 Mac 计算机(任何 Unix 机器都可以这样做)并从一个简单的 bash 脚本将数据发送到打印机.如果使用 Windows 计算机,它的工作方式相同,只需找到一种将二进制数据发送到串行/USB 端口的方法即可.

We are using a Mac computer (any Unix machine will do the same) and send the data to the printer from a simple bash script. If using a Windows computer, it will work the same way, just find a way to send binary data to the serial/USB port.

(我们更喜欢 Unix 机器的原因,因为我们还通过 Internet 与外部服务器数据库通信,这在 Unix 脚本中是一项简单的任务).

(The reason a Unix machine is preferred by us, because we also communicate to an external server database via Internet, an easy task in Unix scripting).

所有的 Unix 机器都有 'lp' 命令,它可以向打印机发送二进制数据.我在 bash 终端中编写了一个脚本,它解析其参数,将它们复制到数据"变量,然后将此数据"变量发送到打印机.

All Unix machines have 'lp' command, which can send binary data to printer. I wrote a script in bash terminal, which parces its arguments, copies them to 'data' variable, then sends this 'data' variable to the printer.

简而言之,一个小标签可以这样打印:

In short, a small label can be printed like this:

data="\x1Bia\x00"       # set esc_p mode
data="${data}\x1B@"     # initialize printer (resets many variables)
data="${data}\x1BX\x32" # set font height
data="${data}Hello"     # the actual data to be printed
data="${data}\x0C"      # advances the page (basically prints the label)

# Check your binary on the screen (for debugging):
echo -ne $data | hexdump -C

# Send the data to the printer
echo -ne $data | lp -d Brother_PT_P900W

当然,您必须将Brother_PT_P900W"替换为您自己的打印机名称.

Of course, you must replace the 'Brother_PT_P900W' with your own printer name.

这篇关于Brother 打印机 Esc/P的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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