LinuxCommandLibrary

barcode

TLDR

Generate a barcode as PostScript

$ barcode -b "[data]" -o [output.ps]
copy
Generate a barcode as EPS
$ barcode -b "[data]" -e EPS -o [output.eps]
copy
Generate Code 39 barcode
$ barcode -e code39 -b "[DATA123]" -o [output.ps]
copy
Generate EAN-13 barcode
$ barcode -e ean -b "[5901234123457]" -o [output.ps]
copy
Generate Code 128 barcode
$ barcode -e code128 -b "[data]" -o [output.ps]
copy
Generate barcode without text label
$ barcode -b "[data]" -n -o [output.ps]
copy
Set custom dimensions
$ barcode -b "[data]" -g [100x50] -o [output.ps]
copy

SYNOPSIS

barcode [-e encoding] [-b string] [-o file] [options]

DESCRIPTION

barcode is a GNU utility that generates barcodes in various formats from textual data. It produces PostScript or EPS output that can be printed directly, converted to other formats, or embedded in documents.
The tool supports all major 1D barcode symbologies used in retail, logistics, and inventory management. Each encoding has specific rules for valid characters and optional check digits. The tool automatically calculates check digits for formats that require them.
Output can be customized with different sizes, margins, and label options. Table mode allows generating sheets of labels for batch printing.

PARAMETERS

-b string

Data to encode in the barcode.
-e encoding
Barcode encoding type (ean, upc, code39, code128, etc.).
-o file
Output file (default: stdout).
-g WxH
Barcode geometry (width x height in points).
-n
No text; suppress human-readable label below barcode.
-t WxH
Table mode: generate multiple barcodes per page.
-m margin
Margin size around barcode.
-p pagesize
Page size (a4, letter, etc.).
-u unit
Unit for dimensions (mm, in, pt).
-E
Output as EPS (Encapsulated PostScript).
-P
Output as PCL (for HP printers).

SUPPORTED ENCODINGS

ean / ean13: European Article Number (13 digits)
upc / upc-a: Universal Product Code
isbn: International Standard Book Number
code39: Code 39 (alphanumeric)
code128: Code 128 (high-density)
code93: Code 93
i25: Interleaved 2 of 5
cbr / codabar: Codabar
msi: MSI Plessey
pls: Plessey

CAVEATS

Output is PostScript/EPS only; conversion to PNG or other raster formats requires tools like Ghostscript or ImageMagick. Not all encodings accept all characters; Code 39 is uppercase only, EAN/UPC require specific digit counts. Check digit validation is performed automatically but data must be valid for the chosen encoding.

HISTORY

GNU barcode was written by Alessandro Rubini and first released in the late 1990s as part of the GNU project. It was designed for use with Unix printing systems and document preparation workflows. While newer tools and libraries have emerged for generating barcodes in various formats, GNU barcode remains useful for its simplicity and PostScript output quality.

SEE ALSO

qrencode(1), zint(1), gs(1)

Copied to clipboard