Search code examples
barcodezpl

How can I create a GTIN14 bar code in ZPL?


Can I print a GTIN-14 barcode using ZPL? I have searched, but can't find much information on weather or not it is possible to print this type of bar code, including the border around it.

Any help is greatly appreciated.

Thanks!


Solution

  • GTIN-14 is simply an interleaved 2 of 5 barcode with bearer bars and special text formatting. Assuming a 203dpi printer and an approximate x-dimension of 25 mils (.64mm), you can calculate all the dimensions of the barcode and its border box.

    • 25mils is approximately 5 dots at 203dpi.
    • The barcode height should be 1.25 inches, which is ~250 dots.
    • The border around the barcode should be the width of the wide bar (3x narrow, or 15 dots).
    • Each character in the barcode is 45 dots (9 modules * 5 dots).
    • The start/stop also adds 45 dots (9 modules * 5 dots).
    • So the total length of the barcode is 15 * 45 dots = 675 dots.
    • Quite zone is 0.25 inches (50 dots) left and right of the barcode.
    • So the box around the barcode is 805 dots wide (15 border + 50 quiet + 675 barcode + 50 quiet + 15 border) and 280 dots high (15 border + 250 barcode + 15 border).

    Here's how it looks in ZPL:

    ^XA
    ^FO100,100^BY5,3
    ^B2N,250,N,N,N
    ^FD00012345678905^FS
    ^FO35,85^GB805,280,15^FS
    ^FO115,380^AB,44,28^FD0 00 12345 67890 5^FS
    ^XZ
    

    The top left corner of the barcode is at 100,100. The top left corner of the border box is at 35,85.

    The example uses the built-in B font, you may want to change that...

    And here it is in labelary.