divendres, 8 de maig del 2009

Dot matrix printer from a webpage

In Amidasoft we've got a customer that needs to print tree copies of his documents. He has solved it by using a dot matrix printer and autocopying paper. I have to say that it was really painful to develop a print engine for JasperReports that helped to do such a print.
It works quite well, and it's been in production since mid 2007. But now, they've requested us to develop a web application (in PHP) and to, somehow, enable clients to print in a dotmatrix printer directly...
The question is: how could we send ESC/P commands to the printer from a web page?

Before starting to develop anything (the project has not yet been approved), I can think nof two alternatives:
  1. Use a signed java applet that opens the printer port and sends data and control characters directly

  2. Render a webpage with control characters on it and use javascript's document.print()

It's amazing how a task as simple as printing a document can become shuch a hard work just by trying to use an outdated technology (as dot-matrix printers) together with a "new" one (as a web application).
I hope I'll be able, in a short time, to post a manual on how we did the work...