Skip to content

Commit c81b09b

Browse files
author
Hugo Osvaldo Barrera
committed
Update README and fix non-restructured formatting
1 parent aaf2982 commit c81b09b

File tree

1 file changed

+160
-150
lines changed

1 file changed

+160
-150
lines changed

README.rst

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

0 commit comments

Comments
 (0)