PHP-GTK2 Newsletter

PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou




Barcode printing on receipt printer using the ESC/POS Commands
Written by kksou   
Wednesday, 16 April 2008

This article shows you the ESC/POS commands for the printing of barcodes on standard Epson receipt printer such as the Epson TM-T88III.

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

The ESC/POS commands are a set of proprietary POS printer command system developed by EPSON.

If you have a different printer, please refer to the corresponding codes in your printer manual. But Epson is pretty much the industry standard for receipt printer and most receipt printers support these ESC/POS commands. You can just try the commands below. Most likely it will work on your receipt printer.

GS f

Note: GS below refers to hexadecimal number "1D".

Description: Select barcode font
Format: GS f n
n=0
Font A
n=1
Font B

Note: this assumes that your receipt printer comes with 2 built-in barcode fonts.

PHP sample code:
fwrite($handle, chr(hexdec('1D')).'f'.chr(0));

GS H

Description: Sets the position of where you want to print the barcode text
Format: GS H n
n=0
Don't print any text
n=1
Above the barcode
n=2
Below the barcode
n=3 Both above and below the barcode
PHP sample code:
fwrite($handle, chr(hexdec('1D')).'H'.chr(2));

GS w

Description: Sets the width of the barcode
Format: GS w n
n=1
n=2
n=3
PHP sample code:
fwrite($handle, chr(hexdec('1D')).'w'.chr(2));

GS h

Description: Sets the height of the barcode
Format: GS h n
where n is between 1 and 255.
Each n corresponds to approximately 0.14mm, or 1/180 inch.
n=60
n=80
n=100
PHP sample code:
fwrite($handle, chr(hexdec('1D')).'h'.chr(100));

GS k

Please refer to the following article for details: How to print barcode using GS k (ESC/POS Command)

Resources on barcodes

Here are some useful links on barcodes:



User reviews   Average user ratings:    3.0   (from 3 users)
  1. RM Flagg
    October 03, 2008 2:13pm
    Any chance on finishing?

    So far, this was a big help in getting a TM-T88III to print using Linux Bash scripts. I can get everything to work *except* bar codes using GS k and everything that goes with it.
    Any chance of finishing GS k?
    Thanks!

  2. kksou
    October 05, 2008 6:56pm

    Hi RM,

    Thanks for the reminder. I've been busy adding some other new stuff to this site that I forgot about this!

    Will try to dig out the manual and finish that off.

    Regards,
    /kksou

  3. kksou
    October 08, 2008 6:40am

    ok. it's done!

    Regards,
    /kksou

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

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