if you're using a label printer, the label printer will have primitives for that. If you're using a normal high-resolution laser or bubblejet, I would suggest looking into barcode support with the GD graphics library.
Also, this issue is off-topic for dbi-users; after finding a bar code graphics library that is supposed to work, follow up to their users list for help with it. Have a nice day
