We are looking to print to a POS printer connected where apache is running. Due to design of the application, and deployment, printing should be done from Server (it should detect the order and send to different printers and different formats of printing…bill, kitchen orders, and so on…). For this reason and others (like access application from an iPad for example) we discard options like QZ-Print applet and needst o print directly server side.
We searched a lot, and found that there are an extension called php-printer but seems outdated, and just works under WIndows.
We followed this code: (http://mocopat.wordpress.com/2012/01/18/php-direct-printing-printer-dot-matrix-lx-300/)
$tmpdir = sys_get_temp_dir(); # ambil direktori temporary untuk simpan file. $file = tempnam($tmpdir, 'ctk'); # nama file temporary yang akan dicetak $handle = fopen($file, 'w'); $condensed = Chr(27) . Chr(33) . Chr(4); $bold1 = Chr(27) . Chr(69); $bold0 = Chr(27) . Chr(70); $initialized = chr(27).chr(64); $condensed1 = chr(15); $condensed0 = chr(18); $corte = Chr(27) . Chr(109); $Data = $initialized; $Data .= $condensed1; $Data .= "==========================\n"; $Data .= "| ".$bold1."OFIDZ MAJEZTY".$bold0." |\n"; $Data .= "==========================\n"; $Data .= "Ofidz Majezty is here\n"; $Data .= "We Love PHP Indonesia\n"; $Data .= "We Love PHP Indonesia\n"; $Data .= "We Love PHP Indonesia\n"; $Data .= "We Love PHP Indonesia\n"; $Data .= "We Love PHP Indonesia\n"; $Data .= "--------------------------\n"; $Data .= $corte; fwrite($handle, $Data); fclose($handle); copy($file, "//localhost/KoTickets"); # Lakukan cetak unlink($file);
And it works, but this sends plain text, and we need to send image (logo), and format a more cute bill. We tried creating a PDF and "sending" to the printer in the same way, but just prints blank.
I found a library to work with network printers (escpos-php on github), but we need to work with USB printers too, to avoid our customers to change hardware.
Some ideas how to achieve this?
Thanks in advance.