Простейший способ создания штрих-кода в формате PNG из командной строки в Linux Ubuntu
В Linux есть огромное количество способов создания линейного штрих-кода. В данной статье мы рассмотрим, как сгенерировать графическое изображение штрих-кода прямо из командной строки. При этом, решение будет совершенно бесплатным и очень простым как в установке, так и в использовании.
- Описание
- Подробнее
Описание
Итак, в Linux мы имеем прекрасную утилиту для генерации штрих-кода под названием barcode. Данная команда генерирует штрих-код в формате PostScript и Encapsulated Postscript.
Рассмотрим её описание:
$ barcode -h
barcode: Options:
-i <arg> input file (strings to encode), default is stdin
-o <arg> output file, default is stdout
-b <arg> string to encode (use input file if missing)
-e <arg> encoding type (default is best fit for first string)
-u <arg> unit ("mm", "in", ...) used to decode -g, -t, -p
-g <arg> geometry on the page: [<wid>x<hei>][+<margin>+<margin>]
-t <arg> table geometry: <cols>x<lines>[+<margin>+<margin>]
-m <arg> internal margin for each item in a table: <xm>[,<ym>]
-n "numeric": avoid printing text along with the bars
-c no Checksum character, if the chosen encoding allows it
-E print one code as eps file (default: multi-page ps)
-P create PCL output instead of postscript
-p <arg> page size (refer to the man page)
Known encodings are (synonyms appear on the same line):
"ean", "ean13", "ean-13", "ean8", "ean-8"
"upc", "upc-a", "upc-e"
"isbn"
"39", "code39"
"128c", "code128c"
"128b", "code128b"
"128", "code128"
"128raw"
"i25", "interleaved 2 of 5"
"cbr", "codabar"
"msi"
"pls", "plessey"
"code93", "93"Как видите, данная команда генерирует штрих-коды во всех основных стандартах.
Рассмотрим примеры использования:
Grand & Toy # 99773,
Label width: 44 mm Label height: 12 mm Horizontal gap between labels 8 mm Vertical gap between labels: 1 mm Top margin: 13 mm Left margin: 8 mm
Should be:
yes 12345 | head -72 | barcode -p 8.5x11in -umm -t 4x18+8+13 -g 44x12+8+1 -e CODE39 > test.ps
But in fact:
yes 12345 | head -84 | barcode -p 8.5x11in -umm -t 4x21+0+0-0-12.8 -g 36x12+7+0 -m 5,0 -e CODE39 > test.ps; date '+%H:%M:%S'

