PHP / JAVASCRIPT 无需对话框即可打印原始数据

发布于 2024-11-07 22:12:55 字数 266 浏览 0 评论 0原文

我目前正在为客户的 PHP Web 应用程序添加功能。他们需要能够直接从 php 将一些原始数据打印到票证/热敏打印机,该 php 将在自助服务亭的互联网浏览器上运行。

数据需要在本地自助服务终端的内置票据打印机上打印。

从我的初步研究中,我了解到我必须使用 javascript 来执行此任务以执行任何客户端操作,并想知道是否有人知道任何方法或示例函数可以允许将字符串打印到指定的打印机/com 端口,从而绕过打印机对话框?

预先感谢您的帮助

亚历克斯

I am currently adding features to a PHP web application for a client. They require to be able to print some raw data to a ticket / thermal printer direct from the php which will be run on an internet browser from a self service kiosk.

The data needs to printed on the local kiosk's in built ticket printer.

From my preliminary research I understand that I must perform this task using javascript for any client side actions and wondered if anybody knew of any method or example function that will allow the printing of a string to a designated printer / com port which would bypass the printer dialog box?

Thanks in advance for any help

Alex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南…巷孤猫 2024-11-14 22:12:55

该插件需要安装 Java 客户端,但在第一个安全提示后,这将执行您需要的操作(适用于 Linux、Mac、Windows、Solaris - 任何可以运行 Java 桌面应用程序的设备)

https://github.com/qzind/tray

This plugin requires Java installed client-side, but after the first security prompt, this will do what you need (works with Linux, Mac, Windows, Solaris -- anything that can run Java desktop application)

https://github.com/qzind/tray

美人迟暮 2024-11-14 22:12:55

如果它必须跨浏览器和平台独立,请立即停止并运行。没有办法,我的意思是 Javascript 没有办法访问有关打印机、边距、纸张尺寸和打印机中所有变量的信息。即使您的浏览器有某种快速打印按钮,使用默认设置和默认打印机进行打印,您也不知道纸张类型、墨水、边距等,并且您可能在 A4 纸上打印,或者在美国打印,我们的法定尺寸,8.5 英寸 X 11.5 英寸。

出于安全考虑,浏览器不会让 JavaScript 访问由 Windows API 和打印机驱动程序提供的此信息。据我所知,最接近的可能是在小型网络中,其中变量是已知的,并使用 Internet Explorer 的 JScript 或 ActiveX 进行配置。除此之外,您唯一的另一个简单选择是编写自己的网络浏览器/插件/插件,或者修改将在这些平台上运行的具有此内置功能的浏览器/插件/插件。

更多信息请参见此处

编辑:如果你真的想让你的生活变得简单,请告诉他们安装 Firefox,并查看 这篇文章可能是最简单的解决方案。另外,你考虑过VBScript吗?它具有这种功能,我以前见过它。

If it has to be cross browser and platform independent, stop right now and run. There is NOT way, and I mean NO way for Javascript to access information about printers, margins, paper size, and all the variables in printers. Even if your browser has some sort of fast print button, print using default settings and default printers, you have no idea the type of paper, the ink, the margins, etc, and you could be printing on A4 paper, or in the US, our legal size, 8.5" X 11.5".

Browsers, for security, do NOT give javascript any access to this information that is supplied to them by the Windows API and the printer drivers. The closest possible that I know of, is in small networks, where the variables are known, and configured using Internet Explorer's JScript or ActiveX. Short of this, your only other easy option is to write your own web browser/addon/plugin, or to modify one that will run on these platforms, that has this built in capability.

More info available here.

EDIT: Though if you really want to make your life simple, tell them to install Firefox, and check out this article for the simplest solution possible. Also, have you considered VBScript? It has this capability, I've seen it done before.

沧桑㈠ 2024-11-14 22:12:55

不可能,至少在没有一些额外步骤的情况下不可能。

如果不了解更多有关信息亭环境的信息,您有三个主要选择:

1)。在本地信息亭上安装 Web 服务。该 Web 服务将管理打印并最终成为最具可扩展性的解决方案。

2)。为打印服务创建一个插件。这会更丑陋,并且真的将您永远束缚在单一浏览器解决方案上。

3)。将浏览器封装在自定义代码中以允许外部调用。同样,有点难看,但由于您正在运行一个信息亭,因此您可能会拥有某种自定义/可扩展的包装器。

Not possible, at least not without some extra steps.

Without knowing more about the kiosk environment, you have three main options:

1). Install a Web service on the local kiosk. This Web service would manage printing and ultimately be the most extensible solution.

2). Create a plug-in for the print service. This would be uglier, and really tie you to a single browser solution forever.

3). Wrap the browser in custom code to allow external calls. Again, somewhat ugly, but since you're running a kiosk, you're likely to have some sort of custom/extensible wrapper anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文