From 2f6aca3c0d342ef3550150ec596904eefbbb6410 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Sat, 23 Apr 2022 18:29:04 +0200 Subject: [PATCH] Label: Changed defaults and barcode size --- container/views.py | 13 +++++++------ labelprinter/labels.py | 10 +++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/container/views.py b/container/views.py index 5341a91..a8698d2 100644 --- a/container/views.py +++ b/container/views.py @@ -105,12 +105,13 @@ class ContainerPrintLabelView(LoginRequiredMixin, generic.DetailView): fmt='image', description=container_description, description_line2=container_description_line2, - writer_options={'font_size': 14, - 'module_height': 10.0, - 'quiet_zone': 4.5, - 'text': 'This is the text', - 'text_distance': 1.0 - }) + writer_options={}) + '''writer_options={'font_size': 14, + 'module_height': 10.0, + 'quiet_zone': 4.5, + 'text': 'This is the text', + 'text_distance': 1.0 + })''' context['barcode_img'] = pil_to_html_imgdata(label_image, fmt='PNG') context['logs'].append('Image created') if num_copies > 0: diff --git a/labelprinter/labels.py b/labelprinter/labels.py index 24650f1..bdc4a29 100644 --- a/labelprinter/labels.py +++ b/labelprinter/labels.py @@ -110,7 +110,15 @@ def container_label(data, barcode_class='code128', fmt='png', logo_file='./stati 'image': python_barcode.writer.ImageWriter }[fmt] barcode_img = constructor(data, writer=writer()) - img = barcode_img.render(writer_options=options['writer_options']) + writer_options = { + 'font_size': 24, + 'module_width': 0.25, + 'module_height': 10, + 'quiet_zone': 3, + 'text_distance': 1.0 + } + writer_options.update(options['writer_options']) + img = barcode_img.render(writer_options=writer_options) barcode_xsize, barcode_ysize = img.size logo_xsize, logo_ysize = logo_img.size label_xsize = 696