Barcode Objects

A barcode object is created by the print barcode (GS k) command. Specified within the command is the symbology to be used, the amount of data to be encoded, and the data itself. Other attributes of the barcode, such as height and width, can be set using other commands.

The set barcode height (GS h) command specifies the height of the barcode in dots, or 1/8th mm. The maximum height for a barcode is 256 dots, or 32 mm. In cases where a taller barcode is needed, a second barcode can be printed below the first at the same left offset.

The set barcode module width (GS w) and set barcode element width (GS W) commands can be used to alter the width of the barcode. See the command descriptions for a full explanation of the differences between these two commands.

The POSTNET barcode symbology is an exception and does not respond to any of these commands. Instead, it always prints within the U.S. Postal Service’s specifications.

The limitations of each symbology must be adhered to when sending data for a barcode. For example, you should not send alphabetic characters to symbologies that only accept numeric data (like the UPC/EAN symbology).

Other items must also be considered when printing barcodes. You must leave sufficient blank space on either side of the barcode to create a quiet zone. You must also select a good ratio/element size if the default values are not being used, and you must allow adequate room for the barcode to be printed on the label. If you ignore any of these items, the barcode that is printed may be unreadable.

In general, you should be very familiar with using barcodes if you want to ensure success.

A barcode object is self-terminating and will be processed as soon as it has received the last byte of data required to define to it. The print barcode (GS k) command’s second parameter specifies whether a fixed amount of data will be sent or whether delimiters will be used. In either case, the data sent must match the parameter setting. If a fixed number of characters are specified, then the exact number of characters specified must be sent. If delimiters are indicated, then matching characters must be sent before and after the barcode data to specify the beginning and end of the data. If an incorrect number of characters or delimiters are sent, the printer will not print correctly.

Barcodes that are too long to fit within the printable area of a label are truncated or do not print at all. This usually results in an unreadable barcode being printed. To correct this condition, you must set a narrower ratio, encode fewer digits, or use a more compact symbology.