def generate_lable(text,project_id,unit_number, project_abriviation): l = zpl.Label(100,60) height = 2 l.origin(0,2) l.write_text(text,char_height=10, char_width=8, line_width=60, justification='C') l.endorigin() qr_code_text = 'QA,%s,%s,%s' % (text,unit_number,project_id) print(qr_code_text) l.origin(2,17) l.write_barcode(height=70,barcode_type='Q',mode='2',mask='1',magnification=10) l.write_text(qr_code_text) l.endorigin() l.origin(15,15) l.write_text('Unit: %s' % (unit_number),char_height=8, char_width=8, line_width=60, justification='C') l.endorigin() l.origin(13, 26) l.write_text(project_abriviation, char_height=6, char_width=6, line_width=60, justification='C') l.endorigin() print_job(l.dumpZPL())
def printZebra(self): l = zpl.Label(60,60) l.origin(0,20) l.write_text(str(self.numero), char_height=10, char_width=8, line_width=60, justification='C') l.endorigin() l.preview()
def print_image(image_path, com): label = zpl.Label(100, 60) height = 10 image_width = 60 label.origin((label.width - image_width) / 2, height) image_height = label.write_graphic(Image.open(image_path), image_width) label.endorigin() zpl_image = label.dumpZPL() with serial.Serial(com) as ser: print("Sending Image to Printer....") # Send Image ser.write(zpl_image.encode("utf-8"))
def create_zpl(images): '''Create ZPL from Image''' payload_zpl = [] for image in images: if isinstance(image, Image.Image): loaded_image = image else: try: loaded_image = Image.open(image) except: raise NotImplementedError( "The image argument needs to be an Image() instance, the filename to an image, or a file handle." ) label = zpl.Label(LABEL_HEIGTH, LABEL_WIDTH, PRINTER_DPMM) label.set_darkness(30) label.origin(PRINT_OFFSET, 0) label.write_graphic(loaded_image, LABEL_WIDTH, LABEL_HEIGTH) label.endorigin() payload_zpl.append(label.dumpZPL()) return payload_zpl
def _get_fedex_zpl(self): packing_slips = [] for pack in self.package_ids: #Header l = zpl.Label(100, 60) l.origin(0, 3) l.write_text("Packing Slip", char_height=2, char_width=2, line_width=60, justification='C') l.endorigin() l.origin(4, 7) l.write_text("Ship TO: %s" % self.partner_id.street, char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(12, 9.8) l.write_text("%s %s" % (self.partner_id.city, self.partner_id.zip), char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(12, 12) l.write_text( "%s (%s)" % (self.partner_id.state_id.name, self.partner_id.state_id.code), char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(12, 14) l.write_text(self.partner_id.country_id.name, char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(40, 7) l.write_text("Order#: %s" % self.origin, char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(40, 10) l.write_text("Date: %s" % datetime.date.today().strftime('%m/%d/%Y'), char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(40, 12) l.write_text("Ship Date: %s" % self.scheduled_date.strftime('%m/%d/%Y'), char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() #Table header l.origin(5, 20) l.write_text("SKU", char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(50, 20) l.write_text("Qty", char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(4, 19) l.draw_box(700, 50, thickness=2, color='B', rounding=0) l.endorigin() if pack.quant_ids: for quant in pack.quant_ids: #Table Body l.origin(5, 25) l.write_text(quant.product_id.default_code, char_height=4, char_width=4, line_width=60) l.endorigin() l.origin(50, 25) l.write_text(int(quant.quantity), char_height=4, char_width=4, line_width=60) l.endorigin() else: for move_line in self.move_line_ids: if move_line.result_package_id == pack: # Table Body l.origin(5, 25) l.write_text(move_line.product_id.default_code, char_height=4, char_width=4, line_width=60) l.endorigin() l.origin(50, 25) l.write_text(int(move_line.product_uom_qty), char_height=4, char_width=4, line_width=60) l.endorigin() l.origin(4, 30) l.write_text("Dealer# %s" % (self.sale_id.partner_id.name or self.sale_id.partner_id.email), char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(3, 32) l.write_text( "--------------------------------------------------------------------------", char_height=1, char_width=1, line_width=60, justification='L') l.endorigin() l.origin(20, 37) l.write_barcode(height=70, barcode_type='C', check_digit='Y') l.write_text(self.get_order()) l.endorigin() l.origin(4, 50) l.write_text( "DO NOT REMOVE OR COVER THIS BARCODE.REQUIRED FOR RETURNS", char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(28, 52) l.write_text("PROCESSING", char_height=2, char_width=2, line_width=60, justification='L') l.endorigin() l.origin(18, 62) l.write_barcode(height=70, barcode_type='C', check_digit='Y') l.write_text(self.sale_id.name) l.endorigin() l.endorigin() zpl_rm_code = l.dumpZPL().replace('^FB720,1,0,L,0', '') packing_slips.append(zpl_rm_code) return packing_slips
#Print both the text and logo labels for the dimsum box internal package import os from PIL import Image import zpl import time labelLogo = zpl.Label(57, 57) labelLogo.origin(28, 2) labelLogo.set_darkness(30) labelLogo.write_graphic(Image.open('top.png'), width=50) labelLogo.endorigin() printStr = bytes(labelLogo.dumpZPL(), encoding='utf8') text_file = open("printLabel.zpl", "wb") text_file.write(printStr) text_file.close() textLabel = ['Xiao Long Bao'] labelText = zpl.Label(57, 57) labelText.origin(25, 25) labelText.write_text("Char Siu So", char_height=6, char_width=6, line_width=60, justification='C') labelText.endorigin() printStr = bytes(labelText.dumpZPL(), encoding='utf8') text_file = open("textLabel.zpl", "wb") text_file.write(printStr) text_file.close()
import os from PIL import Image import zpl l = zpl.Label(60, 60) height = 0 l.origin(0, 20) l.write_text(98, char_height=10, char_width=8, line_width=60, justification='C') l.endorigin() print(l.dumpZPL()) l.preview()
#! /usr/bin/python import os from PIL import Image import zpl noPrint = 1 label = zpl.Label(160, 40) label.origin(35, 20) label.set_darkness(30) label.write_graphic(Image.open('redSilk.png'), width=38) label.endorigin() printStr = bytes(label.dumpZPL(), encoding='utf8') text_file = open("printLabel.zpl", "wb") text_file.write(printStr) text_file.close() for i in range(noPrint): os.system("lp -o raw printLabel.zpl")
product_number = file_product_number.readline() file_product_number.close() file_product.close() number = int(product_number) + 1 label_product = product + str(number) file_product_number = open("product_number.txt", "w") file_product_number.write(str(number)) file_product_number.close() file_product = open("product.txt", "w") file_product.write(str(label_product)) file_product.close() l = zpl.Label(30, 100) height = 0 l.origin(0, 0) l.write_text("Nazov produktu", char_height=3, char_width=3, line_width=20, justification='C') l.endorigin() l.origin(0, 5) l.write_text("Cislo produktu", char_height=3, char_width=3, line_width=20,