def print_product_label_large(product_id, product_ref, product_ean, qty): """ Print the Labels on the GK420t on 70mm width x 2.5mm height labels """ #print product_id #print product_ref #print product_ean #print qty medium = PrinterCupsAdapter( printer_queue_name=PRINTER_LARGELABEL_QUEUE_NAME) d = ZplDocument(target_encoding=PRINTER_ENCODING, printer_adapter=medium, title='%i x %s' % (qty, product_ref)) # Start a Print format d.format_start() # Set Quantity if qty > 1: d.print_quantity(qty) # Write a BarCode field d.field(origin=(175, 11), font=d.font('T', 17, 8), data=unicode(product_ref)) # use font E as default d.ean13(origin=(500, 62), ean=unicode(product_ean), height_dots=50) d.field(origin=(630, 160), font=d.font('T', 17, 8), data=unicode(product_id).rjust(4)) # use font E by default d.field(origin=(225, 150), font=d.font('C'), data=u'MC Hobby sprl - shop.mchobby.be') d.field(origin=(255, 175), font=d.font('C'), data=u'Happy Electronic Hacking!') # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del (medium)
def print_quantity_doc(): """ Print the ean13 document IN MULTIPLE QUANTITY on Zebra. """ # 3232 is used for belgian courrier, let say the following '1' to identify product and 576 for id_product ean_base = '323210000576' ean13 = calculate_ean13(ean_base) print ean13 print('Print the EAN13 (%02i) ZPL document' % PRINTER_QUANTITY) print('----------------------------------') medium = PrinterCupsAdapter(printer_queue_name=PRINTER_QUEUE_NAME) d = ZplDocument(target_encoding=PRINTER_ENCODING, printer_adapter=medium, title='Barcode doc x %i' % PRINTER_QUANTITY) # Start a Print format d.format_start() # Set Quantity d.print_quantity(PRINTER_QUANTITY) # Write a BarCode field d.field(origin=(120, 11), font=d.font('E'), data=u'RASPBERRY.') d.field(origin=(120, 42), font=d.font('E'), data=u'Pi.2......') d.ean13(origin=(130, 80), ean=unicode(ean13), height_dots=50) d.field(origin=(140, 160), font=d.font('C'), data=u'MC Hobby sprl') d.field(origin=(130, 180), font=d.font('C'), data=u'shop.mchobby.be') # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del (medium)
def print_product_label_large( product_id, product_ref, product_ean, qty ): """ Print the Labels on the GK420t on 70mm width x 2.5mm height labels """ #print product_id #print product_ref #print product_ean #print qty medium = PrinterCupsAdapter( printer_queue_name = PRINTER_LARGELABEL_QUEUE_NAME ) d = ZplDocument( target_encoding = PRINTER_ENCODING, printer_adapter = medium, title = '%i x %s' % (qty,product_ref) ) # Start a Print format d.format_start() # Set Quantity if qty > 1: d.print_quantity( qty ) # Write a BarCode field d.field( origin=(175,11), font=d.font('T',17,8), data= unicode( product_ref) ) # use font E as default d.ean13( origin=(500,62), ean=unicode(product_ean), height_dots = 50 ) d.field( origin=(630,160), font=d.font('T',17,8), data=unicode( product_id ).rjust(4) ) # use font E by default d.field( origin=(225,150), font=d.font('C'), data=u'MC Hobby sprl - shop.mchobby.be' ) d.field( origin=(255,175), font=d.font('C'), data=u'Happy Electronic Hacking!' ) # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del( medium )
def print_quantity_doc( ): """ Print the ean13 document IN MULTIPLE QUANTITY on Zebra. """ # 3232 is used for belgian courrier, let say the following '1' to identify product and 576 for id_product ean_base = '323210000576' ean13 = calculate_ean13( ean_base ) print ean13 print( 'Print the EAN13 (%02i) ZPL document' % PRINTER_QUANTITY ) print( '----------------------------------' ) medium = PrinterCupsAdapter( printer_queue_name = PRINTER_QUEUE_NAME ) d = ZplDocument( target_encoding = PRINTER_ENCODING, printer_adapter = medium, title = 'Barcode doc x %i' % PRINTER_QUANTITY ) # Start a Print format d.format_start() # Set Quantity d.print_quantity( PRINTER_QUANTITY ) # Write a BarCode field d.field( origin=(120,11), font=d.font('E'), data=u'RASPBERRY.' ) d.field( origin=(120,42), font=d.font('E'), data=u'Pi.2......' ) d.ean13( origin=(130,80), ean=unicode(ean13), height_dots = 50 ) d.field( origin=(140,160), font=d.font('C'), data=u'MC Hobby sprl' ) d.field( origin=(130,180), font=d.font('C'), data=u'shop.mchobby.be' ) # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del( medium )
def print_product_label( product_id, product_ref, product_ean, qty ): """ Print the Labels on the Zebra LP 2824 on 1.25" x 1" labels """ #print product_id #print product_ref #print product_ean #print qty medium = PrinterCupsAdapter( printer_queue_name = PRINTER_SHORTLABEL_QUEUE_NAME ) d = ZplDocument( target_encoding = PRINTER_ENCODING, printer_adapter = medium, title = '%i x %s' % (qty,product_ref) ) # Start a Print format d.format_start() # Set Quantity if qty > 1: d.print_quantity( qty ) # Label is printed with 2 lines of 10 characters l1 = product_ref[:10] l2 = product_ref[10:] # Write product name # we will try to offer a human redeable text (2x10 chars) on the # label properly cut the text around ' ', '-' iPos = max( l1.rfind( ' ' ), l1.rfind( '-' ) ) if iPos == -1 or iPos == 9 or len( product_ref ) <= 10: # The text too short or not appropriate to cute it. # Just cut it without care. l1 = product_ref.ljust(20)[:10] l2 = product_ref.ljust(20)[10:] else: iShouldMove = 10 - (iPos+1) if len( l2 )+ iShouldMove <= 10: # if second line would not exceed max len ? # We go for nicely cutting it! l2 = l1[iPos+1:] + l2 l1 = l1[:iPos+1] else: # Keep the cut without care l1 = product_ref.ljust(20)[:10] l2 = product_ref.ljust(20)[10:] d.field( origin=(120,11), font=d.font('E'), data= unicode( l1 ) ) d.field( origin=(120,42), font=d.font('E'), data= unicode( l2 ) ) # Write a BarCode field d.ean13( origin=(130,80), ean=unicode(product_ean), height_dots = 50 ) d.field( origin=(130,160), font=d.font('C'), data=u'shop.mchobby.be' ) d.field( origin=(98,185), font=d.font('C'), data=u'MC Hobby sprl' ) d.field( origin=(265,185), font=d.font('E',17,8), data=unicode( product_id ).rjust(4) ) # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del( medium )
def print_product_label(product_id, product_ref, product_ean, qty): """ Print the Labels on the Zebra LP 2824 on 1.25" x 1" labels """ #print product_id #print product_ref #print product_ean #print qty medium = PrinterCupsAdapter( printer_queue_name=PRINTER_SHORTLABEL_QUEUE_NAME) d = ZplDocument(target_encoding=PRINTER_ENCODING, printer_adapter=medium, title='%i x %s' % (qty, product_ref)) # Start a Print format d.format_start() # Set Quantity if qty > 1: d.print_quantity(qty) # Label is printed with 2 lines of 10 characters l1 = product_ref[:10] l2 = product_ref[10:] # Write product name # we will try to offer a human redeable text (2x10 chars) on the # label properly cut the text around ' ', '-' iPos = max(l1.rfind(' '), l1.rfind('-')) if iPos == -1 or iPos == 9 or len(product_ref) <= 10: # The text too short or not appropriate to cute it. # Just cut it without care. l1 = product_ref.ljust(20)[:10] l2 = product_ref.ljust(20)[10:] else: iShouldMove = 10 - (iPos + 1) if len( l2 ) + iShouldMove <= 10: # if second line would not exceed max len ? # We go for nicely cutting it! l2 = l1[iPos + 1:] + l2 l1 = l1[:iPos + 1] else: # Keep the cut without care l1 = product_ref.ljust(20)[:10] l2 = product_ref.ljust(20)[10:] d.field(origin=(120, 11), font=d.font('E'), data=unicode(l1)) d.field(origin=(120, 42), font=d.font('E'), data=unicode(l2)) # Write a BarCode field d.ean13(origin=(130, 80), ean=unicode(product_ean), height_dots=50) d.field(origin=(130, 160), font=d.font('C'), data=u'shop.mchobby.be') d.field(origin=(98, 185), font=d.font('C'), data=u'MC Hobby sprl') d.field(origin=(265, 185), font=d.font('E', 17, 8), data=unicode(product_id).rjust(4)) # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del (medium)