Search code examples
phpprintingescpos

Web-based printing to a remote local thermal receipt printer


I have a web-based point of sale application on PHP apache. User access the POS from another computer (within the network) to perform the transaction, then print on their local machine. Currently the print format is in html, displayed and printed on the user machine.

I am planning to add support for receipt printer like epson thermal or dot matrix, star. I have searched code escpos php code that might be good for printing to these printers. (https://github.com/mike42/escpos-php)

I read that this script prints locally on server machine or networked printer. But problem is, the printer I am using on the client side only support USB or serial/parallel. How do I send escpos character directly from server to client printer?


Solution

  • To be able access local USB deviced via the Webserver would be a huge security risk. Just think of a "evil" server that prints the whole wikipedia on any printer connected to a client, for example.

    I don't think that there is a way to access any client-connected USB device with a simple web-based server software. I would suggest either to

    1. get a receipt printer that shows up as a regular printer and just styling your receipts accordingly
    2. write a Thick Client instead or
    3. write a "print-agent" that regularly checks the server if there is any job for the locally connected receipt printer.

    Either way, I do not think that, at this point, there is much use for PHP.

    You could, of course, try tunneling USB via IP, but that would be quite a hassle to setup and maintain.