Skip to main content

A simple module for creating barcodes.

Project description

PubCode is a library that encodes barcodes and allows easy access to the data required to render the barcode. It can optionally use PIL to render the barcode or to provide a data URL containing a single pixel high PNG barcode which can be resized by a browser to a more usefull size.

Supported barcodes

  • Code128

Usage

>>> from pubcode import Code128
>>> barcode = Code128('Hello!', charset='B')

You can access the data required to render the barcode easily and intuitively.

>>> barcode.bars
'2112142311131122142211142211141341112221221212412331112'
>>> barcode.modules  # doctest: +ELLIPSIS
[0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, ...]

You can generate PIL.Image objects from barcodes.

>>> barcode.image()  # doctest: +ELLIPSIS
<PIL.Image.Image image mode=1 size=121x1 at ...>
>>> barcode.image(height=10, module_width=2)  # doctest: +ELLIPSIS
<PIL.Image.Image image mode=1 size=242x10 at ...>

You can also generate data URLs.

>>> barcode.data_url()  # doctest: +ELLIPSIS
'data:image/png;base64,...'

You can also control the exact way in which the barcode is encoded, which allows you to control the size of the resulting barcode.

>>> barcode = Code128('12\x00x\x01', charset='CABA')
>>> barcode.symbols
['[Start Code C]', '12', '[Code A]', '\x00', '[Shift B]', 'x', '\x01', '\x15', '[Stop]']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PubCode-1.0.0-py2.py3-none-any.whl (8.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file PubCode-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for PubCode-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e557eec2e04196d6171a7e4e20f0841d547bd3098e655d272d8c7d1cc9566e3f
MD5 7b2ca956ec5d1dada217c2cc1c614fc5
BLAKE2b-256 eedd51095a0b3bd78a3b4f93ef3b999ce8d3420f189c52dc878317e602ae4aea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page