我在 openerp7 中使用此代码直接从打印机打印此代码是我在 main.py 中编写的,但是当我启动服务器时,它在我的浏览器控制台上给出了未处理的错误,实际上这个错误发生在导入 win32print 模块时。
import win32print
printer=OpenPrinter(win32print.GetDefaultPrinter())
hJob = win32print.StartDocPrinter (printer, 1, ("RVGI Print", None, "RAW"))
g=open('test3.txt','r')
raw_data = bytes ( open( 'test3.txt' , 'r').read ())
try:
win32print.StartPagePrinter (printer)
win32print.WritePrinter (printer, raw_data)
win32print.EndPagePrinter (printer)
finally:
win32print.EndDocPrinter (printer)
win32print.ClosePrinter (printer)