用Python打开till-through打印机

2024-05-08 00:48:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我有爱普生TM-U220B网络打印机和一个现金抽屉。我正在开发pythonweb应用程序,我设法在我的应用程序上配置打印机。我的打印机工作正常,我只想开到我打印票的时候。我在网上找到了一些打开抽屉的密码。在

代码如下:

def print_(printer_name, file_path):
    preorder = chr(27)+chr(100)+chr(0)    
    cut_paper = chr(29)+chr(86)+chr(66)+chr(0)

    open_till = chr(27)+chr(112)+chr(10)

    the_file = open(file_path, "a")
    the_file.seek(0)
    the_file.write(preorder)
    the_file.seek(0,2)
    the_file.write(cut_paper)
    the_file.write(open_till)
    the_file.close()
    conn.printFile(printer_name, file_path, md5(file_path), {})

开放的密码是不起作用的代码,其他一切都可以

谢谢你


Tags: thepath代码name应用程序密码打印机open
1条回答
网友
1楼 · 发布于 2024-05-08 00:48:43

你可以用下面的代码打开现金抽屉

import win32print

def OpenCashDrawer(printerName) :   
       printerHandler = win32print.OpenPrinter(printerName)
       cashDraweOpenCommand = chr(27)+chr(112)+chr(0)+chr(25)+chr(250)
       win32print.StartDocPrinter(printerHandler, 1, ('Cash Drawer Open',None,'RAW')) 
       win32print.WritePrinter( printerHandler, cashDraweOpenCommand)
       win32print.EndDocPrinter(printerHandler)
       win32print.ClosePrinter(printerHandler)

OpenCashDrawer("YourPrinterName")

相关问题 更多 >