Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Print Thermal Receipt Printer

I own Sewoo Thermal Printer that is connected to a local PHP point of sale. Now as a simple print test using php, I wrote the following code :

<?php
$handle = printer_open("THERMAL LK-TXXX");
$handle = printer_open();
?>

And I got this Error :

Fatal error: Call to undefined function printer_open() in C:\wamp\www\frame\reciept.php on line 2

I'm using Wampp as my web server, Windows 7 and I've installed the correct drivers for my printer. How can i fix this problem, Or is there an alternative "Print" methode using PHP to automatically print without showing Print preview?

Thank You

like image 333
Alihamra Avatar asked Sep 19 '26 16:09

Alihamra


1 Answers

A POS printer is (mostly) not a printer in the sense of using the Windows printing functions to create output, that is quite independent of the device, but simply a sink for serial data in the printer's control language (we built a ticketing system driving very similar printers).

One approach is to user the Win32API extension for PHP and the OpenDriver API, but this turns out to be quite a mess. Best way is to simply fopen() the printer port and write your PCL data via fwrite()

like image 50
Eugen Rieck Avatar answered Sep 22 '26 07:09

Eugen Rieck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!