Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
win32print
#1
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/win3..._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?
Reply
#2
There is so little available on this package.
Might I suggest https://pypi.org/project/win32printing/ instead
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020