Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top