Skip to content

Commit f1c363d

Browse files
author
Thorsten Weimann
committed
Merged in iconberg/python-barcode/iconberg/writerpy-edited-online-with-bitbucket--1421226143420 (pull request #3)
Some improvements
2 parents 1da2d2f + 58da2da commit f1c363d

2 files changed

Lines changed: 195 additions & 165 deletions

File tree

README.rst

Lines changed: 150 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,150 @@
1-
pyBarcode
2-
=========
3-
4-
This library provides a simple way to create barcodes using only the
5-
Python standardlib. The barcodes where created as SVG objects.
6-
7-
Report bugs at https://bitbucket.org/whitie/python-barcode/issues/
8-
9-
10-
Requirements
11-
------------
12-
13-
- Setuptools/distribute for installation (new in version 0.7beta4)
14-
- Python 2.6 or above (including Python 3.x)
15-
- On Python 2.6, 3.0, 3.1: argparse (for the commandline script)
16-
- Program to open SVG objects (your browser should do it)
17-
- Optional: PIL to render barcodes as images (PNG, JPG, ...)
18-
19-
20-
Installation
21-
------------
22-
23-
Make sure you have setuptools/distribute installed.
24-
25-
Unpack the downloaded file, cd into the pyBarcode directory and run
26-
`python setup.py install`. Or just copy the barcode dir somewhere in
27-
your PYTHONPATH.
28-
29-
The best way is to use pip: `pip install pyBarcode`.
30-
31-
32-
Provided Barcodes
33-
-----------------
34-
35-
EAN-8, EAN-13, UPC-A, JAN, ISBN-10, ISBN-13, ISSN, Code 39, Code 128, PZN
36-
37-
38-
Todo
39-
----
40-
41-
- Add documentation
42-
- Add more codes
43-
- Improve Python 3 support
44-
- Add simple GUI
45-
46-
Usage
47-
-----
48-
49-
Interactive::
50-
51-
>>> import barcode
52-
>>> barcode.PROVIDED_BARCODES
53-
[u'code39', u'code128', u'ean', u'ean13', u'ean8', u'gs1', u'gtin',
54-
u'isbn', u'isbn10', u'isbn13', u'issn', u'jan', u'pzn', u'upc', u'upca']
55-
>>> EAN = barcode.get_barcode_class('ean13')
56-
>>> EAN
57-
<class 'barcode.ean.EuropeanArticleNumber13'>
58-
>>> ean = EAN(u'5901234123457')
59-
>>> ean
60-
<barcode.ean.EuropeanArticleNumber13 object at 0x00BE98F0>
61-
>>> fullname = ean.save('ean13_barcode')
62-
>>> fullname
63-
u'ean13_barcode.svg'
64-
# Example with PNG
65-
>>> from barcode.writer import ImageWriter
66-
>>> ean = EAN(u'5901234123457', writer=ImageWriter())
67-
>>> fullname = ean.save('ean13_barcode')
68-
u'ean13_barcode.png'
69-
# New in v0.4.2
70-
>>> from StringIO import StringIO
71-
>>> fp = StringIO()
72-
>>> ean.write(fp)
73-
# or
74-
>>> f = open('/my/new/file', 'wb')
75-
>>> ean.write(f) # PIL (ImageWriter) produces RAW format here
76-
# New in v0.5.0
77-
>>> from barcode import generate
78-
>>> name = generate('EAN13', u'5901234123457', output='barcode_svg')
79-
>>> name
80-
u'barcode_svg.svg'
81-
# with file like object
82-
>>> fp = StringIO()
83-
>>> generate('EAN13', u'5901234123457', writer=ImageWriter(), output=fp)
84-
>>>
85-
86-
Now open ean13_barcode.[svg|png] in a graphic app or simply in your browser
87-
and see the created barcode. That's it.
88-
89-
Commandline::
90-
91-
$ pybarcode{2,3} create "My Text" outfile
92-
New barcode saved as outfile.svg.
93-
$ pybarcode{2,3} create -t png "My Text" outfile
94-
New barcode saved as outfile.png.
95-
96-
Try `pybarcode -h` for help.
97-
98-
Changelog
99-
---------
100-
101-
:v0.8: Code 128 added. Data for charsets and bars moved to subpackage
102-
barcode.charsets.
103-
104-
:v0.7: Fixed some issues with fontsize and fontalignment.
105-
Added Python 3 support. It's not well tested yet, but the tests
106-
run without errors with Python 3.3. Commandline script added.
107-
108-
:v0.6: Changed save and write methods to take the options as a dict
109-
not as keyword arguments (fix this in your code). Added option
110-
to left align the text under the barcode. Fixed bug with EAN13
111-
generation.
112-
113-
:v0.5.0: Added new generate function to do all generation in one step.
114-
Moved writer from a subpackage to a module (this breaks some
115-
existing code). UPC is now rendered as real UPC, not as EAN13
116-
with the leading "0".
117-
118-
:v0.4.3: Fixed bug in new write method (related to PIL) and updated docs.
119-
120-
:v0.4.2: Added write method to support file like objects as target.
121-
122-
:v0.4.1: Bugfix release. Removed redundancy in input validation.
123-
EAN8 was broken. It now works as expected.
124-
125-
:v0.4: Removed \*\*options from writers __init__ method. These options never
126-
had effect. They were always overwritten by default_options.
127-
New config option available: text_distance (the distance between
128-
barcode and text).
129-
130-
:v0.4b2: Basic documentation included. The barcode object now has a new
131-
attribute called `raw` to have the rendered output without saving
132-
to disk.
133-
134-
:v0.4b1: Support for rendering barcodes as images is implemented.
135-
PIL is required to use it.
136-
137-
:v0.3: Compression for SVG output now works.
138-
139-
:v0.3b1: Writer API has changed for simple adding new (own) writers.
140-
SVG output is now generated with xml.dom module instead of
141-
stringformatting (makes it more robust).
142-
143-
:v0.2.1: API of render changed. Now render takes keyword arguments
144-
instead of a dict.
145-
146-
:v0.2: More tests added.
147-
148-
:v0.1: First release.
149-
1+
![example_ean13.png](https://bitbucket.org/repo/rXdyBE/images/1631728592-example_ean13.png)
2+
3+
pyBarcode
4+
=========
5+
6+
This library provides a simple way to create barcodes using only the
7+
Python standardlib. The barcodes where created as SVG objects.
8+
9+
Report bugs at https://bitbucket.org/whitie/python-barcode/issues/
10+
11+
12+
Requirements
13+
------------
14+
15+
- Setuptools/distribute for installation (new in version 0.7beta4)
16+
- Python 2.6 or above (including Python 3.x)
17+
- On Python 2.6, 3.0, 3.1: argparse (for the commandline script)
18+
- Program to open SVG objects (your browser should do it)
19+
- Optional: PIL to render barcodes as images (PNG, JPG, ...)
20+
21+
22+
Installation
23+
------------
24+
25+
Make sure you have setuptools/distribute installed.
26+
27+
Unpack the downloaded file, cd into the pyBarcode directory and run
28+
`python setup.py install`. Or just copy the barcode dir somewhere in
29+
your PYTHONPATH.
30+
31+
The best way is to use pip: `pip install pyBarcode`.
32+
33+
34+
Provided Barcodes
35+
-----------------
36+
37+
EAN-8, EAN-13, UPC-A, JAN, ISBN-10, ISBN-13, ISSN, Code 39, Code 128, PZN
38+
39+
40+
Todo
41+
----
42+
43+
- Add documentation
44+
- Add more codes
45+
- Improve Python 3 support
46+
- Add simple GUI
47+
48+
Usage
49+
-----
50+
51+
Interactive::
52+
53+
>>> import barcode
54+
>>> barcode.PROVIDED_BARCODES
55+
[u'code39', u'code128', u'ean', u'ean13', u'ean8', u'gs1', u'gtin',
56+
u'isbn', u'isbn10', u'isbn13', u'issn', u'jan', u'pzn', u'upc', u'upca']
57+
>>> EAN = barcode.get_barcode_class('ean13')
58+
>>> EAN
59+
<class 'barcode.ean.EuropeanArticleNumber13'>
60+
>>> ean = EAN(u'5901234123457')
61+
>>> ean
62+
<barcode.ean.EuropeanArticleNumber13 object at 0x00BE98F0>
63+
>>> fullname = ean.save('ean13_barcode')
64+
>>> fullname
65+
u'ean13_barcode.svg'
66+
# Example with PNG
67+
>>> from barcode.writer import ImageWriter
68+
>>> ean = EAN(u'5901234123457', writer=ImageWriter())
69+
>>> fullname = ean.save('ean13_barcode')
70+
u'ean13_barcode.png'
71+
# New in v0.4.2
72+
>>> from StringIO import StringIO
73+
>>> fp = StringIO()
74+
>>> ean.write(fp)
75+
# or
76+
>>> f = open('/my/new/file', 'wb')
77+
>>> ean.write(f) # PIL (ImageWriter) produces RAW format here
78+
# New in v0.5.0
79+
>>> from barcode import generate
80+
>>> name = generate('EAN13', u'5901234123457', output='barcode_svg')
81+
>>> name
82+
u'barcode_svg.svg'
83+
# with file like object
84+
>>> fp = StringIO()
85+
>>> generate('EAN13', u'5901234123457', writer=ImageWriter(), output=fp)
86+
>>>
87+
88+
Now open ean13_barcode.[svg|png] in a graphic app or simply in your browser
89+
and see the created barcode. That's it.
90+
91+
Commandline::
92+
93+
$ pybarcode{2,3} create "My Text" outfile
94+
New barcode saved as outfile.svg.
95+
$ pybarcode{2,3} create -t png "My Text" outfile
96+
New barcode saved as outfile.png.
97+
98+
Try `pybarcode -h` for help.
99+
100+
Changelog
101+
---------
102+
103+
:v0.8: Code 128 added. Data for charsets and bars moved to subpackage
104+
barcode.charsets.
105+
106+
:v0.7: Fixed some issues with fontsize and fontalignment.
107+
Added Python 3 support. It's not well tested yet, but the tests
108+
run without errors with Python 3.3. Commandline script added.
109+
110+
:v0.6: Changed save and write methods to take the options as a dict
111+
not as keyword arguments (fix this in your code). Added option
112+
to left align the text under the barcode. Fixed bug with EAN13
113+
generation.
114+
115+
:v0.5.0: Added new generate function to do all generation in one step.
116+
Moved writer from a subpackage to a module (this breaks some
117+
existing code). UPC is now rendered as real UPC, not as EAN13
118+
with the leading "0".
119+
120+
:v0.4.3: Fixed bug in new write method (related to PIL) and updated docs.
121+
122+
:v0.4.2: Added write method to support file like objects as target.
123+
124+
:v0.4.1: Bugfix release. Removed redundancy in input validation.
125+
EAN8 was broken. It now works as expected.
126+
127+
:v0.4: Removed \*\*options from writers __init__ method. These options never
128+
had effect. They were always overwritten by default_options.
129+
New config option available: text_distance (the distance between
130+
barcode and text).
131+
132+
:v0.4b2: Basic documentation included. The barcode object now has a new
133+
attribute called `raw` to have the rendered output without saving
134+
to disk.
135+
136+
:v0.4b1: Support for rendering barcodes as images is implemented.
137+
PIL is required to use it.
138+
139+
:v0.3: Compression for SVG output now works.
140+
141+
:v0.3b1: Writer API has changed for simple adding new (own) writers.
142+
SVG output is now generated with xml.dom module instead of
143+
stringformatting (makes it more robust).
144+
145+
:v0.2.1: API of render changed. Now render takes keyword arguments
146+
instead of a dict.
147+
148+
:v0.2: More tests added.
149+
150+
:v0.1: First release.

0 commit comments

Comments
 (0)