Thermal printers are really good at printing barcodes! This printer supports 11 different codes - UPC A, UPC E, EAN13, EAN8, CODE39, I25, CODEBAR, CODE93, CODE128, CODE11 and MSI. It only supports linear (1-D) barcodes, and can’t generate 2-D barcodes like QR codes (although there is a hack you can do, see below!) Barcodes are generated “on the fly,” which is nice — you can customize the height and data included quite easily.
You can make a barcode by calling printBarcode("barcodedata", BARCODETYPE), where the first string is the data to encode (e.g. a UPC code) and BARCODETYPE can be UPC_A, UPC_E, EAN13, EAN8, CODE39, I25, CODEBAR, CODE93, CODE128, CODE11 or MSI.
Some barcodes are very restricted — you can only put in 12 numbers, no characters. Others are very flexible and take nearly any character input. Please check out the wikipedia list detailing kinds of barcodes to pick the right one for your application.
The available range of barcodes varies with the printer firmware revision. Check Adafruit_Thermal.h for a list of codes.
It’s also possible to print QR codes, if you’re willing to pre-generate them. This might be handy if you want to, let’s say, include a URL on the receipt and the URL doesn’t change. You can generate QR codes at many sites including this one. Use the smallest QR code size. The image will be in PNG format, so if you’re using the Windows LCD Assistant tool you’ll need to convert it to BMP first (Windows Paint works for this). Then you can convert and embed this in your Arduino sketch as previously described.