簡體   English   中英

在 Python 中打印 PDF 文件,但在使用 Z23EEEB4347BDD75BFC6B7EE93 之前顯示打印機屬性對話框 window

[英]Print a PDF File in Python but show the printer properties dialog window before using python

我目前正在編寫一個腳本,該腳本將根據我的要求裁剪 PDF 文件並將它們合並到 pdf 文件中。 這應在之后通過默認打印機直接打印,但使用側面打印機托盤並以 A6 格式打印。 因此,我希望腳本在打印之前打開打印機屬性對話框 window。

我說的是這個對話框 window

我很感激任何幫助,因為我已經在互聯網上搜索了無數小時

我終於找到了解決方案。 希望這也可以幫助您/您正在尋找什么。

import win32print

# access defaults
PRINTER_DEFAULTS = {"DesiredAccess": win32print.PRINTER_ALL_ACCESS}

# open printer to get the handle
pHandle = win32print.OpenPrinter(name,PRINTER_DEFAULTS)

# get the current properties
properties = win32print.GetPrinter(pHandle, 2)

#get the devmode
pDevModeObj = properties['pDevMode']

#open the printer properties and pass the devmode
win32print.DocumentProperties(0, pHandle, name, pDevModeObj, None, 5)

# reassign the devmode
properties['pDevMode'] = pDevModeObj

# save the printer settings
win32print.SetPrinter(pHandle,2,properties,0)

# close the printer
win32print.ClosePrinter(pHandle)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM