Skip to main content

Create standard barcodes with Python. No external modules needed (optional PIL support included).

Project description

Fork of pyBarcode project.

This library provides a simple way to create barcodes using only the Python standardlib. The barcodes where created as SVG objects.

Requirements

  • Setuptools/distribute for installation (new in version 0.7beta4)

  • Python 2.6 or above (including Python 3.x)

  • On Python 2.6, 3.0, 3.1: argparse (for the commandline script)

  • Program to open SVG objects (your browser should do it)

  • Optional: PIL to render barcodes as images (PNG, JPG, …)

Installation

Make sure you have setuptools/distribute installed.

Unpack the downloaded file, cd into the viivakoodi directory and run python setup.py install. Or just copy the barcode dir somewhere in your PYTHONPATH.

The best way is to use pip: pip install viivakoodi.

Provided Barcodes

EAN-8, EAN-13, EAN-14, UPC-A, JAN, ISBN-10, ISBN-13, ISSN, Code 39, Code 128, PZN

Todo

  • Add documentation

  • Improve Python 3 support

Usage

Interactive:

>>> import barcode
>>> barcode.PROVIDED_BARCODES
[u'code39', u'code128', u'ean', u'ean13', u'ean8', u'gs1', u'gtin',
 u'isbn', u'isbn10', u'isbn13', u'issn', u'jan', u'pzn', u'upc', u'upca']
>>> EAN = barcode.get_barcode_class('ean13')
>>> EAN
<class 'barcode.ean.EuropeanArticleNumber13'>
>>> ean = EAN(u'5901234123457')
>>> ean
<barcode.ean.EuropeanArticleNumber13 object at 0x00BE98F0>
>>> fullname = ean.save('ean13_barcode')
>>> fullname
u'ean13_barcode.svg'
# Example with PNG
>>> from barcode.writer import ImageWriter
>>> ean = EAN(u'5901234123457', writer=ImageWriter())
>>> fullname = ean.save('ean13_barcode')
u'ean13_barcode.png'
# New in v0.4.2
>>> from io import BytesIO
>>> fp = BytesIO()
>>> ean.write(fp)
# or
>>> f = open('/my/new/file', 'wb')
>>> ean.write(f) # PIL (ImageWriter) produces RAW format here
# New in v0.5.0
>>> from barcode import generate
>>> name = generate('EAN13', u'5901234123457', output='barcode_svg')
>>> name
u'barcode_svg.svg'
# with file like object
>>> fp = StringIO()
>>> generate('EAN13', u'5901234123457', writer=ImageWriter(), output=fp)
>>>

Now open ean13_barcode.[svg|png] in a graphic app or simply in your browser and see the created barcode. That’s it.

Commandline:

$ pybarcode{2,3} create "My Text" outfile
New barcode saved as outfile.svg.
$ pybarcode{2,3} create -t png "My Text" outfile
New barcode saved as outfile.png.

Try `pybarcode -h` for help.

Changelog

v0.1:

First release.

Project details


Download files

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

Source Distribution

reBarcode-0.1.0.tar.gz (221.8 kB view details)

Uploaded Source

Built Distribution

reBarcode-0.1.0-py3-none-any.whl (209.4 kB view details)

Uploaded Python 3

File details

Details for the file reBarcode-0.1.0.tar.gz.

File metadata

  • Download URL: reBarcode-0.1.0.tar.gz
  • Upload date:
  • Size: 221.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reBarcode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 53f3d09d2d9106ba776f2626a347597ac29c3b8d942fa8c08083fa27db41f730
MD5 3ff9c533b0dbe3475c82be4e01a72dd1
BLAKE2b-256 2883fa98cadf4398bcb7181b561e8ce93417c85c544de5f3f256c18ce3335c04

See more details on using hashes here.

File details

Details for the file reBarcode-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for reBarcode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02fb984c6cdc17a6db7b4c8abbc070208379c80648a2321f954b1b85113721ef
MD5 bff9fe3cac1eb5cdc7ad7c0881e8f235
BLAKE2b-256 33ae723e2cf937f15f9ebb5aaef4d09b22e7dbcb54a222902af964437af835e4

See more details on using hashes here.

Supported by

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