1

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

5
  • Before I jump in, what internet browser and version of Windows? I'm asking because javascript's window.print() is interpreted differently by browsers, and I believe your solution would have to be either a direct call to the Windows API, or to modify the call made by the browser. Commented May 17, 2011 at 12:24
  • It would ideally need to be cross browser and platform independant as it would be running on multiple kiosk systems. For the sake of an example and working on single solution, lets say internet explorer 7 and windows xp? Commented May 17, 2011 at 12:25
  • 1
    In no case does php code "run on an internet browser". The php code runs as part of the server, even if the server happens to be running on the same machine as the browser. You're going to have to drive the printing from the php code, not the browser. Commented May 17, 2011 at 12:27
  • @Point +1. PHP is definitely not for this, PHP has printer functions, but PHP is not running on the client's computer, only on the server. Commented May 17, 2011 at 12:38
  • Well, @LostInTheCode, it was not clear (and still isn't, really) whether the kiosk is entirely self-contained or whether it communicates with a remote web server. If I were doing it, I'd be strongly inclined to have the kiosk run everything (server & browser), with some other communication back to a host for updates etc. That way the kiosk functionality is independent of continuous Internet connectivity. Of course I have no idea what this application is :-) Commented May 17, 2011 at 12:55

3 Answers 3

5

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

Sign up to request clarification or add additional context in comments.

Comments

2

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.

2 Comments

I am curerently looking through your points but on first look your firefox article looks to be a quick win for now! /i may investigate the VB route and post the results on here but I think looking at other comments I may be better writing a new web service for printing. Big help though this firefox fix should make me hit the deadline for now! PHEW!!
No problem. Don't forget to upvote answers and select accepted answers when you're done ;)
0

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.

1 Comment

Thanks I think the web service solution may well be the long term solution but for now I am gonna hit the firefox hack route just for a quick fix and get the funtionality working. Thanks for your comments!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.