示例#1
0
    def veri():
        df = pd.read_excel(r'C:\Users\DELL\Desktop\barcode_test.xlsx')
        eski_barcode = df['eski'].tolist()
        yeni_barcode = df['yeni'].tolist()
        count = 0
        #dictionary = dict(zip(eski_barcode, yeni_barcode))
        for eski in eski_barcode:
            if readed_barcode_ == str(eski):
                new_barcode_ = yeni_barcode[count]
                print(new_barcode_)

                zdoc = ZPLDocument()
                zdoc.add_comment(" TEX {}".format(new_barcode_))
                zdoc.add_field_origin(20, 20)
                zdoc.add_print_quantity(2)
                code128_data = str(new_barcode_)
                bc = Code128_Barcode(code128_data, 'N', 100, 'Y')
                zdoc.add_barcode(bc)
                print(zdoc.zpl_text)

                # Get PNG byte array
                png = zdoc.render_png(label_width=2, label_height=1)
                # render fake file from bytes
                fake_file = io.BytesIO(png)
                img = Image.open(fake_file)
                # Open image with the default image viewer on your system
                img.show()

            else:
                pass
            count += 1
示例#2
0
def test_field_origin():
    zdoc = ZPLDocument()
    zdoc.add_field_origin(1000, 999, 2)
    assert (zdoc.zpl_bytes == b'^XA\n^FO1000,999,2\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_origin()
    assert (zdoc.zpl_bytes == b'^XA\n^FO0,0\n^XZ')
示例#3
0
    def generateLabel(self,
                      dcNo='0',
                      upc='0',
                      title='',
                      price='$0',
                      ip_add='10.1.10.155',
                      width=2.25,
                      height=1.25):

        zpl = ZPLDocument()
        zpl.add_comment('DC No')
        zpl.add_field_origin(320, 25)
        zpl.add_font('A', zpl._ORIENTATION_NORMAL, 10)
        zpl.add_field_data(str(dcNo))

        zpl.add_comment('UPC')
        upcPos = self.__getUPCPosition(upc)
        zpl.add_field_origin(int(upcPos), 50)
        code128_data = str(upc)
        bc = Code128_Barcode(code128_data, 'N', 50, 'Y')
        zpl.add_barcode(bc)

        zpl.add_comment('Date')
        zpl.add_field_origin(30, 180)
        zpl.add_font('S', zpl._ORIENTATION_NORMAL, 16)
        zpl.add_field_data(datetime.datetime.now().strftime('%d/%m/%Y'))

        zpl.add_comment('Price')
        zpl.add_field_origin(290, 180)
        zpl.add_font('G', zpl._ORIENTATION_NORMAL, 18)
        zpl.add_field_data(str('$' + price))
        self.printZPL(zpl)
示例#4
0
def test_field_origin_error():
    for x_axis in (-1, 32001, 'E', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_origin(x_axis)

    for y_axis in (-1, 32001, 'E', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_origin(10, y_axis)

    for justification in (-1, 3, 'E'):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_origin(10, 10, justification)
示例#5
0
from simple_zpl2 import ZPLDocument, QR_Barcode

zpl = ZPLDocument()

zpl.add_comment('Create a QR Code')
zpl.add_field_origin(20, 20)
qr_data = 'This is data inside a QR code.  This is a barcode often read by cell phones.'
qr = QR_Barcode(qr_data, 2, 2, zpl._QR_ERROR_CORRECTION_STANDARD)
zpl.add_barcode(qr)

zpl.add_comment('Now some text')
zpl.add_field_origin(200, 20)
zpl.add_font('C', zpl._ORIENTATION_NORMAL, 15)
zpl.add_field_data('Text on Label')

# Print generated text
print(zpl.zpl_text)
示例#6
0
from simple_zpl2 import ZPLDocument, Code128_Barcode

# Each label is built with a ZPLDocument object
zdoc = ZPLDocument()
zdoc.add_comment("Barcode and text")
zdoc.add_field_origin(20, 20)
code128_data = 'TEST BARCODE'
bc = Code128_Barcode(code128_data, 'N', 30, 'Y')
zdoc.add_barcode(bc)
print(zdoc.zpl_text)