Printing to Dot Matrix printers from Web Apps

santiagoIT picture santiagoIT · Jul 29, 2010 · Viewed 16.7k times · Source

I am not familiar with Dot Matrix printers but I have a customer with a WebApp that generates invoices, print checks, etc.. Currently they are printing directly from the server, meaning that the printer must be connected to the server or that the server needs a way to connect to the remote printer. As you can imagine this generates a lot of problems.

My first reaction was, generate a pdf doc. on the server and send it to the client so they can print it on whichever printer they have access to. But it turns out that many of his customers use dot matrix printers which do not support printing of PDF.

My question, is there any file format that all dot matrix printers can read? HTML, ASCII, etc... My customer insists that the only way to go is to have the server print directly from php which seems extremely odd to me.

Thank you in advance!

Answer

Gagan Bhatia picture Gagan Bhatia · Dec 9, 2011

I see that though this question is posted quite some back and already solution is selected but some how i feel that the problem is very genuine and still many may be wanting a solution to this as more and more web apps are coming up so hope some may find this solution beneficial.

Printing graphics on the Dotmatrix printer is a very slow as compared to printing plain ascii text.

An invoice which may be printed in less then a minute on a dotmatrix printer can take upto 8-10 minutes to be printed in graphics mode so time is a issue for printing graphics on dotmatrix also apart from time it would mean more wear and tear of the printer head and ribbon and since normally dotmatrix printer is these days primarily used for business applications emphasis is not on quality of print but the data to be printed on paper.

Solution

You can build an executable or a process which is running in memory monitoring a folder which can act as a drop box. (As soon as a file is present in this folder this execuable would send this file to printer.)

for eg if the drop folder path is c:\printoutput

and a file is placed in this as invoice.txt all that the execuable file/print process has to do is send a dos/shell command as

c:\type c:\printoutput\invoice.txt > lpt1 (you can replace lpt1 with prn or any local port where printer is connected)

Web application can simply save the text file to the folder c:\printoutput

The executable file may have constant monitoring / run after specific time span / hotkey to invoke printing as soon as user knows he had put some file in the printfolder to be printed.

Also you can still use Epson ESC codes to use dotmatrix internal font selection or formatting etc by embedding it in the text file.

So you may have absolutely the same formatted print as from the printer connected on the local port of the server.