[python-win32] why do I get error 1804 from win32print.SetJob?

Tim Roberts timr at probo.com
Fri Nov 16 15:08:36 EST 2018


Glenn Linderman wrote:
>
> Here is the code I'm using. Note that the variables js and rename are 
> the control variables if you need to tweak this to run in your 
> environment. js contains a substring of an existing document name, and 
> the idea is that the document name of the first matching spool job 
> having a document name containing that fragment will be changed to the 
> content of the rename variable by the code.
> ...
> Here is the error I'm getting:
>
> {'JobId': 27, 'pPrinterName': 'HL6180dw', 'pMachineName': 
> '\\\\STEPHEN', 'pUserName': 'Glenn', 'pDocument': 'duh', 'pDatatype': 
> 'NT EMF 1.008', 'pStatus': None, 'Status': 8210, 'Priority': 1, 
> 'Position': 0, 'TotalPages': 22, 'PagesPrinted': 0, 'Submitted': 
> pywintypes.datetime(2018, 11, 14, 21, 1, 27, 882000, 
> tzinfo=TimeZoneInfo('GMT Standard Time', True))}
> Traceback (most recent call last):
>   File "D:\my\py\spool.py", line 109, in <module>
>     win32print.SetJob( phandle, res[ 1 ], 1, jobinfo, 0 )
> pywintypes.error: (1804, 'SetJob', 'The specified datatype is invalid.')

That's very odd.  This is not from the Pywin32 code --  it has correctly 
parsed your structure.  That error is coming from the SetJob API itself 
(ERROR_INVALID_DATATYPE).  As an experiment, have you tried coding up 
the exact same sequence as a C program to see if you get the same error?

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list