本文介绍了通过网络直接打印到打印机(如 POS 打印机)的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从网络应用程序打印到联网打印机?是否有任何 POS 或类似外形的打印机可以连接到互联网并直接打印(假设通过路由器打开了一个端口)?

Is it possible to print to a networked printer from a web app? Are there any POS or similar form factor printers which can be connected to the internet and printed to directly(given that a port is opened through the router)?

我的理想情况是一台打印机,我可以将 XML 发送到该打印机并进行打印,而无需 PC,因此无需驱动程序.

My ideal case would be a printer to which I could send XML and have it print without requiring a PC and hence no driver.

另一件好事是创建到打印机的 ssl 连接,但这并不重要.

Another thing that would be good is creating an ssl connection to the printer, but that's not as critical.

推荐答案

大多数热敏 POS 或标签打印机都可以通过制造商的附加网卡连接到网络.大品牌是 Zebra 和 Intermec.

Most thermal POS or label printers can be connected to a network with an add-on network card from the manufacturer. Big brand names are Zebra and Intermec.

有趣的是,这些打印机中的大多数都具有直接的 ASCII 模式,因此您只需连接一个普通的旧 TCP/IP 连接,然后输出一些格式命令等,这些命令是用制造商将使用的专有打印机语言编写的给你.对于 Intermec,它被称为 IPL(Intermec 打印机语言).

The interesting thing is that most of these printers have a direct ASCII mode, so you just connect on a plain old TCP/IP connection and spit out some formatting commands, etc., written in a proprietary printer language that the manufacturer will give you. In the case of Intermec, it's called IPL (Intermec Printer Language).

您有两个选择……您可以让用户单击按钮,刷新页面,然后在服务器端打开与打印机的 TCP/IP 连接并进行打印.这也适用于串行端口打印机和常规 Windows 打印机.事实上,这就是我们在最近的一个项目中实现它的方式.您的第二个选择是编写一些客户端代码,使用 JavaScript 或您所拥有的,以打开与打印机的连接并吐出相同的打印机消息.警告:您这样做可能会遇到安全问题,因为浏览器可能不会善待您的页面启动到随机 IP 地址的出站连接.如果您位于公司防火墙之后,并且可以指望对客户端安全模型进行一些调整,那么这可能是可能的.

You have two options... you can have the user click a button, do a page refresh, and on the server side just open a TCP/IP connection to the printer and print. This would also work for serial port printers and regular windows printers. In fact, this is how we implemented it in a recent project. Your second option is to write some client side code, in JavaScript or what-have-you, to open a connection to the printer and spit out the same printer message. Caveat: you'll probably run into security concerns doing that because the browser may not take kindly to your page initiating outbound connections to random IP addresses. If you're behind a corporate firewall and you can count on doing some tweaking to the client security models, this might be possible.

就我个人而言,我更喜欢从服务器端打印,而不是客户端.

Personally, I prefer printing from the server side, not the client side.

这篇关于通过网络直接打印到打印机(如 POS 打印机)的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 03:56