我知道这个问题以前曾被问过,但没有明确的答案。
如何以编程方式更改打印机纸盒?
我正在尝试使用 python 批量打印一些 PDF。我需要从不同的纸盘打印不同的页面。打印机是理光2232C。有没有办法通过 Acrobat Reader 命令行参数来完成此操作?我可以使用 Win32 api 找出哪些 bin 对应于哪些 binname,但仅此而已。有什么建议/捷径/等等吗?
好吧,我明白了。答案是:
1.您需要本地打印机(如果需要打印到网络打印机,请下载驱动程序并将其添加为本地打印机)
2.使用win32print获取和设置默认打印机
3.同样使用win32print,使用以下代码:
import win32print
PRINTER_DEFAULTS = {"DesiredAccess":win32print.PRINTER_ALL_ACCESS}
pHandle = win32print.OpenPrinter('RICOH-LOCAL', PRINTER_DEFAULTS)
properties = win32print.GetPrinter(pHandle, 2) #get the properties
pDevModeObj = properties["pDevMode"] #get the devmode
automaticTray = 7
tray_one = 1
tray_two = 3
tray_three = 2
printer_tray = []
pDevModeObj.DefaultSource = tray_three #set the tray
properties["pDevMode"]=pDevModeObj #write the devmode back to properties
win32print.SetPrinter(pHandle,2,properties,0) #save the properties to the printer
- 就这样,托盘已经换了
-
打印是使用 Internet Explorer 完成的(来自 Graham King 的博客)
from win32com import client
import time
ie = client.Dispatch("InternetExplorer.Application")
def printPDFDocument(filename):
ie.Navigate(filename)
if ie.Busy:
time.sleep(1)
ie.Document.printAll()
ie.Quit()
Done
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)