Saltar al contenido

EAN-13 barcodes in ZPL with ^BE

To print an EAN-13 barcode in ZPL, send the first 12 digits to ^BE and let the printer add the check digit: ^BY3,2,140^FO80,60^BEN,140,Y,N^FD590123412345^FS prints 5901234123457. If you send 13 digits, the 13th is replaced by the correct check digit.

Actualizado 2026-10-20 · Renderizados hechos con el motor de OpenZPL

Abrir en el visor

Generador

Generando…

Etiqueta de 4 × 2 pulgadas a 203 dpi. Una vista previa muestra cómo la impresora dibuja el código; confirme con un escáner antes de imprimir una serie.

The ^BE command

ParámetroQué haceValores
^BY wModule width, in dots2 to 4 is usual at 203 dpi
^BE oOrientaciónN, R, I, B
^BE hBar height, in dotsfor example 100 to 150
^BE fPrint the digits under the barsY or N
^BE gPrint the digits above the barsY or N

An EAN-13 symbol is 95 modules wide, plus the quiet zones. At 203 dpi a dot is 0.125 mm, so ^BY3 gives 0.375 mm modules and bars 285 dots (35.6 mm) wide, about 114% of the 0.33 mm nominal module. ^BY2 gives 0.25 mm modules, about 76%, below the 80% that GS1 allows for retail point of sale.

EAN-13 barcode 5901234123457 with its digits under the bars
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^XA
^BY3,2,140
^FO80,60^BEN,140,Y,N
^FD590123412345^FS
^XZ

The check digit

The 13th digit is computed from the first 12: add the digits in odd positions, add three times the digits in even positions, and take the amount needed to reach the next multiple of 10. For 590123412345 the weighted sum is 83, so the check digit is 7. See the check digit entry for the step-by-step calculation.

In our test the OpenZPL engine ignores a 13th digit and prints the correct one. Below, the data ends in 0, but the printed and scanned code is 5901234123457. Your database still has the wrong number, so fix it at the source:

^FD5901234123450 (wrong 13th digit)

EAN-13 sent with a wrong last digit: the printed code still ends in 7
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^XA
^BY3,2,140
^FO80,60^BEN,140,Y,N
^FD5901234123450^FS
^XZ

^FD590123412345 (12 digits)

EAN-13 barcode 5901234123457 with its digits under the bars
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^XA
^BY3,2,140
^FO80,60^BEN,140,Y,N
^FD590123412345^FS
^XZ

Invalid data

  • Fewer than 12 digits: nothing is drawn. The OpenZPL API answers 400 Bad Request with ERROR: EAN-13: need at least 12 digits, got 11.
  • Letters or symbols: EAN-13 encodes digits only. The engine skips them and counts the digits left: 59012341234A gets the same 400 and message ("got 11"). Remove them before sending the label.
  • A real product code: EAN-13 numbers are assigned through GS1. Use a prefix from your GS1 membership; 590123412345 is only an example number.

Verifique un código de barras antes de imprimir una tanda

Una vista previa muestra cómo la impresora dibujará el código: anchos de barras, zona muerta y la línea legible por humanos. No prueba que cada escáner lo lea en su medio. Imprima una etiqueta a la densidad real y escáneela con el escáner que utiliza su cliente o transportista; para códigos de venta al por menor y logística, un verificador de códigos de barras califica la calidad de impresión.

Preguntas

Should I send 12 or 13 digits to ^BE?

12. The printer computes the check digit; a 13th digit you send is not used.

Can ^BE print UPC-A?

Use ^BU for UPC-A. A UPC-A number with a leading 0 is the same symbol as an EAN-13.

Fuentes