|
@ -32,6 +32,17 @@ def xstr(s): |
|
|
return '' if s is None else str(s) |
|
|
return '' if s is None else str(s) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_barcode_128_as_base64_png(value): |
|
|
|
|
|
from base64 import b64encode |
|
|
|
|
|
from reportlab.pdfgen import canvas |
|
|
|
|
|
from reportlab.lib.units import mm, inch |
|
|
|
|
|
from reportlab.graphics.barcode import createBarcodeDrawing |
|
|
|
|
|
|
|
|
|
|
|
barcode = createBarcodeDrawing('Code128', value = value, barWidth = 170, height=50, fontSize = 2, humanReadable = True) |
|
|
|
|
|
data = b64encode(barcode.asString('png')) |
|
|
|
|
|
return data.decode('utf-8') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_choices(*choice_pairs): |
|
|
def make_choices(*choice_pairs): |
|
|
assert len(choice_pairs) % 2 == 0 |
|
|
assert len(choice_pairs) % 2 == 0 |
|
|
ipairs = iter(choice_pairs) |
|
|
ipairs = iter(choice_pairs) |
|
|