Python Forum
win32print - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: win32print (/thread-26955.html)



win32print - FritsCornelius - May-19-2020

I'm having a hard time understanding what I'm doing wrong in my code.
I'm only a beginner at programming, but so far enjoying it.

I'm planning to build something that will add all our custom paper sizes to the printer spooler of a computer.
In this code first trying to figure out to add a single paper size. When this works I want to expand it to more.

import win32print

pHandle = win32print.GetDefaultPrinter() 
printer = win32print.OpenPrinter(pHandle)

print(pHandle)
print(printer)

Test=({'Flags': 2, 'Name': 'Test', 'Size': {'cx': 215900, 'cy': 279400}, 'ImageableArea': {'left': 0, 'top': 0, 'right': 215900, 'bottom': 279400}})
win32print.AddForm(0, Test)
win32print.ClosePrinter(printer)
I'm getting the following error:
Error:
Traceback (most recent call last): File "C:\Work\I-Commit\Python\Temp.py", line 10, in <module> win32print.AddForm(0, Test) pywintypes.error: (6, 'AddForm', 'De ingang is ongeldig.')
So far I've looked at the following:
http://timgolden.me.uk/pywin32-docs/win32print__AddForm_meth.html
And tried to google the error, but I'm not finding anything that will help me forward.

Can somebody explain this error and point me in the right direction?


RE: win32print - Larz60+ - May-19-2020

There is so little available on this package.
Might I suggest https://pypi.org/project/win32printing/ instead