Exemplo n.º 1
0
def main():
    imageIn = sys.argv[1]
    fileOut = imageIn + "_tmp.txt"

    p = Dummy()
    p.image(imageIn)
    f = File(fileOut)
    f._raw(p.output)
    f.cut()

    subprocess.call("lpr -P THERMAL -o raw " + fileOut, shell=True)

    os.remove(fileOut)
Exemplo n.º 2
0
def write_order(order, usb_printer=None, print_item_code=True):
    if usb_printer:
        p = usb_printer
    else:
        p = File("/dev/usb/lp0")

    lines = loads(order.lines)

    # Order
    p.text('Order Id: {0}\n'.format(order.id))

    # Table Number
    p.text('Table Number: {0}\n'.format(order.table_no))

    # Take Away
    if order.is_takeaway:
        p.text('Type: TAKE AWAY\n\n')
    else:
        p.text('Type: DINE IN\n\n')

    # Headers
    header_line = line_block([
        {'text': 'Qty', 'align': '<', 'width': QTY_WIDTH},
        {'text': 'Item', 'align': '<', 'width': ITEM_WIDTH},
    ])

    p.text(header_line)

    # Lines
    for line in lines:
        line_text = line_block([
            {'text': line['qty'], 'align': '<', 'width': QTY_WIDTH},
            {'text': line['itemName'], 'align': '<', 'width': ITEM_WIDTH},
        ])
        p.text(line_text)

        if print_item_code:
            item_code = line_block([
                {'text': '-', 'align': '<', 'width': QTY_WIDTH},
                {'text': line['itemCode'], 'align': '<', 'width': ITEM_WIDTH}
            ])
            p.text(item_code)

    # Remarks
    p.text('\nRemarks:\n{0}'.format(order.remarks))

    # Time
    p.text('\n\nPrinted on:\n')
    p.text(time.ctime())

    p.cut()
Exemplo n.º 3
0
def write_order(order, usb_printer=None, print_item_code=True):
    if usb_printer:
        p = usb_printer
    else:
        p = File("/dev/usb/lp0")
    print("ORDER ITEMS")
    lines = []
    for i in order.items:

        lines.append(i.__dict__)
    # Order
    p.text('Order Id: {0}\n'.format(order.id))

    # Table Number
    p.text('Table Number: {0}\n'.format(order.table_no))

    # Take Away

    p.text('Type: {0}\n\n'.format(order.type))

    # Headers
    header_line = line_block([
        {'text': 'Qty', 'align': '<', 'width': QTY_WIDTH},
        {'text': 'Item', 'align': '<', 'width': ITEM_WIDTH},
    ])

    p.text(header_line)

    # Lines
    for line in lines:
        line_text = line_block([
            {'text': line['qty'], 'align': '<', 'width': QTY_WIDTH},
            {'text': line['item_name'], 'align': '<', 'width': ITEM_WIDTH},
        ])
        p.text(line_text)

        if print_item_code:
            item_code = line_block([
                {'text': '-', 'align': '<', 'width': QTY_WIDTH},
                {'text': line['item_code'], 'align': '<', 'width': ITEM_WIDTH}
            ])
            p.text(item_code)

    # Remarks
    p.text('\n\nRemarks:\n{0}'.format(order.remarks))

    # Time
    p.text('\n\nPrinted on:\n')
    p.text(time.ctime())

    p.cut()
Exemplo n.º 4
0
 def printAJsBill(bill, table):
     item_quantitys = bill.getBillSummary()
     bid = str(bill.bid)
     time = str(datetime.now())
     table = table.name.upper()
     total = str(bill.amount)
     epson = File("/dev/usb/lp0")
     Printer.printAJsAddress(bid=bid, table=table, time=time, epson=epson)
     # epson.text('01234567890123456789012345678901\n')
     epson.text('--------------------------------\n')
     epson.set(align='left', text_type='B', width=1, height=1)
     epson.text('Item             Qt  Rate    Amt\n')
     epson.set(align='left', text_type='normal', width=1, height=1)
     epson.text('--------------------------------\n')
     sub_total = 0
     for iq in item_quantitys:
         name = str(iq.get('item').cat)
         cost = str(iq.get('item').cost)
         quantity = str(iq.get('quantity'))
         amount = str(iq.get('quantity') * iq.get('item').cost)
         if len(name) > 16:
             epson.text(txt=name[0:16])
             epson.text(' ')
             Printer.printQuantityCostAndAmount(epson=epson,\
             name=name, cost=cost, quantity=quantity, amount=amount)
             epson.text(txt=name[16:len(name)])
             epson.text(txt='\n')
         else:
             epson.text(txt=name)
             for i in range(16 - len(name)):
                 epson.text(' ')
             epson.text(' ')
             Printer.printQuantityCostAndAmount(epson=epson,\
             name=name, cost=cost, quantity=quantity, amount=amount)
     epson.set(align='left', text_type='B', width=1, height=1)
     epson.text('--------------------------------\n')
     epson.text('TOTAL                   Rs ' + total + '\n')
     epson.text('\n')
     epson.set(align='left', text_type='normal')
     epson.text('COMPOSITION TAXABLE PERSON\n')
     epson.text('GSTIN: 30AFGPG9096R1ZT\n')
     epson.set(align='left', text_type='B')
     epson.text('       FREE HOME DELIVERY       \n')
     epson.text('\n')
     epson.cut()
Exemplo n.º 5
0
 def printKOT(orders, kid):
     epson = File("/dev/usb/lp0")
     epson.text('\n\n\n\n')
     epson.set(text_type='B', width=2, height=2)
     table = orders[0].table
     epson.text('' + table.name + ' KID:' + str(kid) + '\n')
     epson.set(text_type='normal', width=1, height=2)
     for order in orders:
         name = order.item.name
         quantity = order.quantity
         message = str(order.message)
         epson.text(' ' + name)
         epson.set(text_type='U', width=1, height=2)
         epson.text(' ' + message)
         epson.set(text_type='normal', width=1, height=2)
         epson.text(' x' + str(quantity) + '\n')
     epson.cut()
     epson.close()
Exemplo n.º 6
0
def write_order_void(order, usb_printer=None, print_item_code=True):
    if usb_printer:
        p = usb_printer
    else:
        p = File("/dev/usb/lp0")

    lines = []

    for i in order.items:
        lines.append(i.__dict__)

    # Order
    p.text('Void Items')


    # Headers
    header_line = line_block([
        {'text': 'Qty', 'align': '<', 'width': QTY_WIDTH},
        {'text': 'Item', 'align': '<', 'width': ITEM_WIDTH},
    ])

    p.text(header_line)

    # Lines
    for line in lines:
        if line['is_voided']:
            line_text = line_block([
                {'text': line['qty'], 'align': '<', 'width': QTY_WIDTH},
                {'text': line['item_name'], 'align': '<', 'width': ITEM_WIDTH},
            ])
            p.text(line_text)

            if print_item_code:
                item_code = line_block([
                    {'text': '-', 'align': '<', 'width': QTY_WIDTH},
                    {'text': line['item_code'], 'align': '<', 'width': ITEM_WIDTH}
                ])
                p.text(item_code)

    # Time
    p.text('\n\nPrinted on:\n')
    p.text(time.ctime())

    p.cut()
Exemplo n.º 7
0
def main(total_price, datetime):
    try:            
        printer = File(devfile='/dev/usb/lp0')
        printer.profile.media['width']['pixels'] = 575
        printer.image("images/logo-text-small.png", center=True)
        # printer.image("images/logo-text-small.png")
        printer.set(align=u'center')
        printer.text("\n")
        # printer.text('Your ID: ' + str(user_id) + "\n")
        printer.text(total_price + " Toman" + "\n")
        # printer.qr(total_price, size=12, center=True)
        # printer.text('Support: ' + owner_mobile_number + "\n")
        # printer.text('ID: ' + str(owner_id) + "\n")
        printer.text("farazist.ir" + "\n")
        printer.text(datetime)
        printer.cut()
        print("print receipt")
    except Exception as e:
        print("error:", e)
    def printReceipt(self):
        p = File("/dev/usb/lp0", auto_flush=False)
        # Header Receipt
        p.set(align='center', text_type='B')
        p.text("Kantin Wisuda Oktober\n")
        p.text("Institut Teknologi Bandung\n")
        p.text(self.orderTime + "\n")
        # p.text("Rabu,13/02/2019,15:30\n")
        # printTableNumber(orderList[0]['tableNumber'])
        p.text("Nomor Meja: " + str(self.orderList[0]['tableNumber']))
        p.text("\n")
        p.text("Order ID: " + str(self.orderID))
        p.text("\n\n\n")

        # Print Receipt List
        p.set(align='left')
        p.text('\x1b\x44\x00')  # reset tabulation
        p.text('\x1b\x44\x10\x19\x00')  # tabulation setting location
        for item in self.orderList:
            subTotal = item['price'] * item['qty']
            p.text(str(item['menuName']) + "\n")
            p.text(
                str(item['price']) + "\x09" + "x" + str(item['qty']) + "\x09" +
                str(subTotal) + "\n")
        p.text("--------------------------------\n\n")
        p.text("Total Belanja " + "\t" + "\t" + str(self.totalPrice))
        p.text("\n")
        p.set(align='center')
        p.text("Card ID: {}".format(self.cardID))
        p.text("\n")
        p.text("Saldo Akhir: {}".format(formatRupiah(self.balance)))
        p.text("\n\n")
        p.set(align='center')
        p.text("-TERIMAKASIH-")
        p.cut()
        p.flush()
from escpos.printer import File
printer = File(devfile='/dev/usb/lp0')
printer.text("سبسلبلبلل\n")
printer.text("some text\n")
printer.text("some text\n")
printer.text("سبلبلباال\n")

# printer.set(codepage='pc864')
printer.profile.media['width']['pixels'] = 575
printer.image("images/logo-text-small.png", center=True)
# printer.image("images/logo-text-small.png")
# printer.set(align=u'center')
printer.text("Far" + "\n\n")
# printer.text(total_price + " Toman" + "\n")
printer.qr('total_price', size=8, center=True)
# printer.qr(str(self.total_price), size=8)
# printer.text(mobile_number + "\n")
printer.text("farazist.ir" + "\n")
# printer.text(datetime)
printer.cut()
Exemplo n.º 10
0
 def saveToText(self, fn):
     f = File(fn)
     f._raw(self.p.output)
     f.cut()