User Tools

Site Tools


python:barcode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
python:barcode [2016/08/07 15:48] adminpython:barcode [2016/08/09 00:03] – [Custom options in Encoder] admin
Line 1: Line 1:
 ====== Python Barcode ====== ====== Python Barcode ======
 +refer:
 +  * https://github.com/hudora/huBarcode
 +  * https://sourceforge.net/projects/dmsbarcodegener/
 ===== huBarcode ===== ===== huBarcode =====
 refer: https://github.com/hudora/huBarcode refer: https://github.com/hudora/huBarcode
-==== setup huBarcode ====+==== Setup huBarcode ====
   - step1: download hubarcode from https://github.com/hudora/huBarcode   - step1: download hubarcode from https://github.com/hudora/huBarcode
-  - step2: build and install it:<code bat>+  - step2: install python processing image:<code bat> 
 +pip uninstall PIL 
 +pip install pillow 
 +</code> 
 +  - step2: build and install hubarcode:<code bat>
 python setup.py build python setup.py build
 python setup.py install python setup.py install
 +</code>
 +==== Example create Barcode with hubarcode ====
 +Create Firt example **barcode.py** and run it:
 +  - Step1: Create **barcode.py**<code python>
 +import sys
 +from hubarcode.code128 import Code128Encoder
 +if __name__ == '__main__':
 +    print 'barcode generator'
 +    encoder = Code128Encoder(sys.argv[1])
 +    encoder.save("test.png")
 +</code>
 +  - Step2: Run it:<code bat>
 +python barcode.py 123
 +</code>Not run:<code bat>
 +barcode.py 123
 +</code>Because it generate error:<code>
 +ImportError: No module named Image
 +</code>
 +==== Custom options in Encoder ====
 +Below are default options for Code128Encoder:
 +<code python>
 +self.options.get('show_label', True)
 +self.options.get('ttf_fontsize', default_fontsize)
 +self.options.get('ttf_font')
 +self.options.get('label_border', 0)
 +self.image_height = self.options.get('height') or (self.image_width / 3)
 +self.options.get('bottom_border', 0)
 +</code>
 +Create Custom options:<code python>
 +options['height'] = 25
 +options['ttf_fontsize'] = 8
 +options['bottom_border'] = 2
 </code> </code>
python/barcode.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1