PHP-GTK2 Newsletter

PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou



Sample Code 397: How to interface to receipt printer in a point of sale system?
Written by kksou   
Sunday, 23 December 2007
Problem

This is in response to duez1981's post titled 'php-gtk2 point of sale system'.

He is writing a point-of-sale (POS) system using PHP-GTK2, and he wants to know how to link to a receipt printer as shown below.

How to interface to receipt printer in a point of sale system?


Solution
  • A standard receipt printer such as the Epson TM-T88III receipt printer uses the parallel port.
  • To print to the parallel-port receipt printer, you print through port PRN (exactly the same as printing from DOS prompt).
  • From within PHP-GTK2, you need to first establish the connection with the printer by using
    $handle = fopen("PRN", "w");
  • Thereafter, to print anything to the printer, you just "write" to it like the file handle: fwrite($handle, 'text to printer');
  • There are newer receipt printer that uses USB. I believe you should be able to print to such printers through PRN too.

Sample Code
1   
2   
3   
<?php
$handle = fopen("PRN", "w"); // note 1
fwrite($handle, 'text to printer'); // note 2
  • Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
  • Registration is free and immediate.
  • Have some doubt about the registration? Please read this forum article.
Explanation
  1. Establish the connection with the receipt printer through PRN.
  2. Writes to the receipt printer through the file handle.
  3. Disconnect the printer.

Related Links
 

Add comment


Security code
Refresh

< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved