Python win32print 更改高级打印机选项 [英] Python win32print changing advanced printer options

查看:118
本文介绍了Python win32print 更改高级打印机选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 python 2.7 和 win32print.我可以成功地改变纵向和横向之间的方向:

I am using python 2.7 and win32print. I can successfully change the orientation between portrait and landscape:

PRINTER_DEFAULTS = {"DesiredAccess":win32print.PRINTER_ALL_ACCESS}  
pHandle = win32print.OpenPrinter('300LN1', PRINTER_DEFAULTS)  
properties = win32print.GetPrinter(pHandle, 2)  
pDevModeObj.Orientation = 2  
properties["pDevMode"]=pDevModeObj   
win32print.SetPrinter(pHandle,2,properties,0) 

但是,我想为我的打印机更改一些自定义属性,但似乎找不到在哪里执行此操作.这是我想更改的选项卡之一:http://dl.dropbox.com/u/584330/print.jpg.我相信当启用高级打印功能选项"时,可以访问这些选项.

However, I want to change some of the custom properties for my printer but can't seem to find where to do this. This is one of the tabs I want to change: http://dl.dropbox.com/u/584330/print.jpg. I believe that these options are accessible when one enables the "advanced printing features option".

附加信息(代码):

devmode=pDevModeObj  
for n in dir(devmode):  
  print "%s\t%s" % (n,getattr(devmode,n))  

输出:

BitsPerPel  0
Clear   <built-in method Clear of PyDEVMODEA object at 0x028EE750>
Collate 1
Color   2
Copies  1
DefaultSource   15
DeviceName  300LN1
DisplayFixedOutput  19660815
DisplayFlags    1
DisplayFrequency    0
DisplayOrientation  65636
DitherType  4294967295
DriverData  DINU"    DriverExtra    824
DriverVersion   1536
Duplex  1
Fields  92401475
FormName    Letter
ICMIntent   2
ICMMethod   1
LogPixels   0
MediaType   1
Nup 1
Orientation 2
PanningHeight   0
PanningWidth    0
PaperLength 2794
PaperSize   1
PaperWidth  2159
PelsHeight  0
PelsWidth   0
Position_x  65538
Position_y  141495018
PrintQuality    300
Reserved1   0
Reserved2   0
Scale   100
Size    156
SpecVersion 1025
TTOption    2
YResolution 300
__class__   <type 'PyDEVMODEA'>
__delattr__ <method-wrapper '__delattr__' of PyDEVMODEA object at 0x028EE750>
__doc__ None
__format__  <built-in method __format__ of PyDEVMODEA object at 0x028EE750>
__getattribute__    <method-wrapper '__getattribute__' of PyDEVMODEA object at 0x028EE750>
__hash__    <method-wrapper '__hash__' of PyDEVMODEA object at 0x028EE750>
__init__    <method-wrapper '__init__' of PyDEVMODEA object at 0x028EE750>
__new__ <built-in method __new__ of type object at 0x1E7B9970>
__reduce__  <built-in method __reduce__ of PyDEVMODEA object at 0x028EE750>
__reduce_ex__   <built-in method __reduce_ex__ of PyDEVMODEA object at 0x028EE750>
__repr__    <method-wrapper '__repr__' of PyDEVMODEA object at 0x028EE750>
__setattr__ <method-wrapper '__setattr__' of PyDEVMODEA object at 0x028EE750>
__sizeof__  <built-in method __sizeof__ of PyDEVMODEA object at 0x028EE750>
__str__ <method-wrapper '__str__' of PyDEVMODEA object at 0x028EE750>
__subclasshook__    <built-in method __subclasshook__ of type object at 0x1E7B9970>

[edit] 我刚刚尝试了以下代码:

[edit] I just tried the following code:

win32print.DocumentProperties(0, pHandle, '300LN1', None, None, 5)

这会弹出我要修改的属性窗口.

This would pop up the properties window I want to modify.

另外,您知道是否可以要求打印机在打印 300 页后停止打印吗?

Also, do you know if it is possible to ask a printer to stop printing once it hit say 300 pages?

推荐答案

from ctypes import windll
windll['winspool.drv'].AdvancedDocumentPropertiesA(None, pHandle.handle, '300LN1', None, None)

这篇关于Python win32print 更改高级打印机选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆