API Reference

A barcode encoding library supporting over 50 symbologies.

zint.__version__

Version of this package

zint.__upstream_version__

Version of the underlying C Zint implementation

class zint.Symbol

Main symbol structure.

property alphamap

Array of alpha values used (raster output only)

property bgcolor

Background as hexadecimal RGB/RGBA or decimal “C,M,Y,K” string. Alias of bgcolour.

property bgcolour

Background as hexadecimal RGB/RGBA or decimal “C,M,Y,K” string

property bitmap

Stored bitmap image (raster output only)

property border_width

Size of border in X-dimensions

buffer(self: zint.Symbol, rotate_deg: SupportsInt = 0) None

Output a previously encoded symbol to memory as raster (Symbol.bitmap)

buffer_vector(self: zint.Symbol, rotate_deg: SupportsInt = 0) None

Output a previously encoded symbol to memory as vector (Symbol.vector)

static capabilities(symbology: Symbology, /) CapabilityFlags

Return the capability flags for symbology symbology

clear(self: zint.Symbol) None

Free any output buffers that may have been created and initialize output fields

property debug

Debugging flags

static default_xdim(symbology: Symbology, /) float

Return default X-dimension in mm for symbology symbology. Returns 0 on error (invalid symbology)

property dot_size

Size of dots used in BARCODE_DOTTY_MODE. Default 0.8

property dpmm

Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)

property eci

Extended Channel Interpretation. Default 0 (none)

encode(*args, **kwargs)

Overloaded function.

  1. encode(self: zint.Symbol, data: bytes) -> None

Encode a barcode

  1. encode(self: zint.Symbol, text: str) -> None

Encode a barcode

encode_file(self: zint.Symbol, filename: str, /) None

Encode a barcode using input data from file filename

encode_segs(*args, **kwargs)

Overloaded function.

  1. encode_segs(self: zint.Symbol, segs: collections.abc.Sequence[zint.Seg]) -> None

Encode a barcode with multiple ECI segments

  1. encode_segs(self: zint.Symbol, segs: collections.abc.Iterable) -> None

Encode a barcode with multiple ECI segments

property encoded_data

Encoded data (output only). Allows for rows of 1152 modules

property errtxt

Error message if an error or warning occurs (output only)

property fgcolor

Foreground as hexadecimal RGB/RGBA or decimal “C,M,Y,K” string. Alias of fgcolour.

property fgcolour

Foreground as hexadecimal RGB/RGBA or decimal “C,M,Y,K” string

property guard_descent

Height in X-dimensions that EAN/UPC guard bars descend. Default 5

property height

Barcode height in X-dimensions (ignored for fixed-width barcodes)

property input_mode

Encoding of input data (see InputMode). Default InputMode.DATA

property memfile

In-memory file buffer if BARCODE_MEMORY_FILE (output only)

property option_1

Symbol-specific options

property option_2

Symbol-specific options

property option_3

Symbol-specific options

property outfile

Name of file to output to. Default “out.png”

property output_options

Various output parameters (bind, box etc, see OutputOptions)

property primary

Primary message data (MaxiCode, Composite)

print(self: zint.Symbol, rotate_deg: SupportsInt = 0) None

Output a previously encoded symbol to file Symbol.outfile

reset(self: zint.Symbol) None

Free any output buffers that may have been created and reset all fields to defaults

property row_height

Heights of rows (output only). Allows for 200 row DotCode

property rows

Number of rows used by the symbol (output only)

property scale

Scale factor when printing barcode, i.e. adjusts X-dimension. Default 1

static scale_from_xdim_dp(symbology: Symbology, /, x_dim_mm: SupportsFloat, *, dpmm: SupportsFloat, filetype: str | None = None) float

Return the scale to use for symbology for non-zero X-dimension x_dim_mm at dpmm dots per mm for filetype. If dpmm zero defaults to 12. If filetype is None, defaults to “GIF”. Returns 0 on error

property show_hrt

If True, display Human Readable Text (HRT) on supported barcodes. Default True. Alias of Symbol.show_text.

property show_text

If True, display Human Readable Text (HRT) on supported barcodes. Default True

property structapp

Structured Append info. Default structapp.count 0 (none)

property symbology

Symbol type to use (see Symbology)

property text

Human Readable Text (HRT) (if any), UTF-8 (output only)

property text_gap

Gap between barcode and Human Readable Text (HRT) in X-dimensions. Default 1

property vector

Vector header (vector output only)

property warn_level

Affects error/warning value returned by Zint API (see WarningLevel)

property whitespace_height

Height in X-dimensions of whitespace above & below the barcode

property whitespace_width

Width in X-dimensions of whitespace to left & right of barcode

property width

Width of the generated symbol (output only)

static xdim_dp_from_scale(symbology: Symbology, /, scale: SupportsFloat, *, x_dim_mm_or_dpmm: SupportsFloat, filetype: str | None = None) float

Reverse of Symbol.scale_from_xdim_dp. Estimate the X-dimension or dpmm given non-zero scale and non-zero x_dim_mm_or_dpmm. Return value bound to dpmm max not X-dimension max. Returns 0 on error

class zint.Symbology(*values)

Values for Symbol.symbology

CODE11 = 1
C25STANDARD = 2
C25INTER = 3
C25IATA = 4
C25LOGIC = 6
C25IND = 7
CODE39 = 8
EXCODE39 = 9
EANX = 13
EANX_CHK = 14
GS1_128 = 16
CODABAR = 18
CODE128 = 20
DPLEIT = 21
DPIDENT = 22
CODE16K = 23
CODE49 = 24
CODE93 = 25
FLAT = 28
DBAR_OMN = 29
DBAR_LTD = 30
DBAR_EXP = 31
TELEPEN = 32
UPCA = 34
UPCA_CHK = 35
UPCE = 37
UPCE_CHK = 38
POSTNET = 40
MSI_PLESSEY = 47
FIM = 49
LOGMARS = 50
PHARMA = 51
PZN = 52
PHARMA_TWO = 53
CEPNET = 54
PDF417 = 55
PDF417COMP = 56
MAXICODE = 57
QRCODE = 58
CODE128AB = 60
AUSPOST = 63
AUSREPLY = 66
AUSROUTE = 67
AUSREDIRECT = 68
ISBNX = 69
RM4SCC = 70
DATAMATRIX = 71
EAN14 = 72
VIN = 73
CODABLOCKF = 74
NVE18 = 75
JAPANPOST = 76
KOREAPOST = 77
DBAR_STK = 79
DBAR_OMNSTK = 80
DBAR_EXPSTK = 81
PLANET = 82
MICROPDF417 = 84
USPS_IMAIL = 85
PLESSEY = 86
TELEPEN_NUM = 87
ITF14 = 89
KIX = 90
AZTEC = 92
DAFT = 93
DPD = 96
MICROQR = 97
HIBC_128 = 98
HIBC_39 = 99
HIBC_DM = 102
HIBC_QR = 104
HIBC_PDF = 106
HIBC_MICPDF = 108
HIBC_BLOCKF = 110
HIBC_AZTEC = 112
DOTCODE = 115
HANXIN = 116
MAILMARK_2D = 119
UPU_S10 = 120
MAILMARK_4S = 121
AZRUNE = 128
CODE32 = 129
EANX_CC = 130
GS1_128_CC = 131
DBAR_OMN_CC = 132
DBAR_LTD_CC = 133
DBAR_EXP_CC = 134
UPCA_CC = 135
UPCE_CC = 136
DBAR_STK_CC = 137
DBAR_OMNSTK_CC = 138
DBAR_EXPSTK_CC = 139
CHANNEL = 140
CODEONE = 141
GRIDMATRIX = 142
UPNQR = 143
ULTRA = 144
RMQR = 145
BC412 = 146
DXFILMEDGE = 147
class zint.Seg

Segment for use with Symbol.encode_segs.

property eci

Extended Channel Interpretation

property source

Data to encode

class zint.StructApp

Structural append information (see Symbol.structapp).

Ignored unless StructApp.count is non-zero

property count

Number of symbols in Structured Append sequence. Set >= 2 to add SA Info

property id

Optional ID to distinguish sequence, ASCII, max 32 long

property index

Position in Structured Append sequence, 1-based. Must be <= count

class zint.Vector

Vector image information, returned from Symbol.vector after calling Symbol.buffer_vector

property circles

An iterable over circles (VectorCircle)

property height

Height of barcode image (including text, whitespace)

property hexagons

An iterable over hexagons (VectorHexagon)

property rectangles

An iterable over rectangles (VectorRectangle)

property strings

An iterable over strings (VectorString)

property width

Width of barcode image (including text, whitespace)

class zint.VectorCircle

Circle vector elements returned from Vector.circles

property color

Zero for draw with foreground colour (else draw with background colour (legacy)). Alias of colour

property colour

Zero for draw with foreground colour (else draw with background colour (legacy))

property diameter

Circle diameter. Does not include width (if any)

property width

Width of circle perimeter (circumference). 0 for fill (disc)

property x

Centre

property y

Centre

class zint.VectorHexagon

Hexagon vector elements returned from Vector.hexagons

property diameter

Short (minimal) diameter (i.e. diameter of inscribed circle)

property rotation

0, 90, 180, 270 degrees, where 0 has apex at top, i.e. short diameter is horizontal

property x

Centre

property y

Centre

class zint.VectorRect

Rectangle vector elements returned from Vector.rectangles

property color

-1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White. Alias of colour

property colour

-1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White

property height
property width
property x

Left

property y

Top

class zint.VectorString

String vector elements returned from Vector.strings

property fsize

Font size

property halign

0 for centre, 1 for left, 2 for right (end)

Type:

Horizontal alignment

property length

Number of characters (bytes)

property rotation

0, 90, 180, 270 degrees

property text
property width

Rendered width estimate

property x

Relative to halign (i.e. centre, left, right)

property y

Relative to baseline

class zint.CapabilityFlags(*values)

Capability flags (ZBarcode_Cap() cap_flag)

HRT = 1
STACKABLE = 2
EANUPC = 4
COMPOSITE = 8
ECI = 16
GS1 = 32
DOTTY = 64
QUIET_ZONES = 128
FIXED_RATIO = 256
READER_INIT = 512
FULL_MULTIBYTE = 1024
MASK = 2048
STRUCTAPP = 4096
COMPLIANT_HEIGHT = 8192
class zint.DataMatrixOptions(*values)

Data Matrix specific options (symbol->option_3)

SQUARE = 100
DMRE = 101
ISO_144 = 128
class zint.InputMode(*values)

Values for Symbol.input_mode

DATA = 0
UNICODE = 1
GS1 = 2
ESCAPE = 8
GS1PARENS = 16
GS1NOCHECK = 32
HEIGHTPERROW = 64
FAST = 128
EXTRA_ESCAPE = 256
class zint.OutputOptions(*values)

Values for Symbol.output_options

BARCODE_BIND_TOP = 1
BARCODE_BIND = 2
BARCODE_BOX = 4
BARCODE_STDOUT = 8
READER_INIT = 16
SMALL_TEXT = 32
BOLD_TEXT = 64
CMYK_COLOUR = 128
BARCODE_DOTTY_MODE = 256
GS1_GS_SEPARATOR = 512
OUT_BUFFER_INTERMEDIATE = 1024
BARCODE_QUIET_ZONES = 2048
BARCODE_NO_QUIET_ZONES = 4096
COMPLIANT_HEIGHT = 8192
EANUPC_GUARD_WHITESPACE = 16384
EMBED_VECTOR_FONT = 32768
BARCODE_MEMORY_FILE = 65536
class zint.QrFamilyOptions(*values)

QR, Han Xin, Grid Matrix specific options (symbol->option_3)

FULL_MULTIBYTE = 200
class zint.UltracodeOptions(*values)

Ultracode specific option (symbol->option_3)

ULTRA_COMPRESSION = 128
class zint.WarningLevel(*values)

Warning level (symbol->warn_level)

DEFAULT = 0
FAIL_ALL = 2