直接从 HTTP 响应打印
我正在使用 FedEx 运输网络服务。 SOAP 响应包含用于生成运输标签的打印机缓冲区文件。是否可以将其直接发送到打印机,以便文件永远不会存储在本地?换句话说,“打印运输标签”按钮将发出 SOAP 请求,成功响应的结果将是打印机根据 SOAP 响应中的数据打印标签。
我正在使用 PHP,如果有帮助的话。
I'm working with the FedEx shipping web service. The SOAP response contains a printer buffer file that is used to generate a shipping label. Is it possible to send this directly to the printer so that the file is never stored locally? In other words, the button "print shipping label" would make a SOAP request, and the result of a successful response would be that the printer prints a label based on data in the SOAP response.
I'm using PHP, if that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这对于 PHP 是否可行。根据服务器的操作系统,打印的工作方式有很大不同。
最好的选择是将所需的数据写入文件并指示系统的打印服务打印该文件,然后在几分钟后清理该文件。
如果您的打印机支持 IPP,则 这个类可能会有一些帮助,尽管说明似乎表明它还需要磁盘上的文件才能实际执行打印。
I'm not sure this is possible with PHP. Printing works in very different ways based on the operating system of the server.
Your best bet is writing the data you need to a file and instructing the system's printing service to print that file, then clean up the file a few minutes later.
If your printer speaks IPP, then this class might be some help, though the instructions seem to indicate that it also needs a file on disk to actually perform printing.
不是向运输按钮返回 HTML 响应,而是使用 MIME 类型的应用程序/epl2 返回热数据,如果您安装了 UPS 的 ActiveX 控件,则数据将假脱机到您的打印机。
如果您需要在发货后更新 UI,那么您需要以某种方式存储数据(磁盘、会话变量等),也许还需要更新 UI,然后对二进制数据进行 http 重定向以便打印。
Rather than returning a HTML response to the ship button, return the thermal data with a MIME type of application/epl2 and if you have the ActiveX control from UPS installed, the data will be spooled to your printer.
If you need to update the UI after shipping then you'll need to store the data somehow (disk, session variable, etc.) and perhaps update the UI but then do a http redirect to the binary data so it prints.