[python-win32] how to change paper size while printing

Roger Upole rwupole at msn.com
Fri May 30 06:15:53 CEST 2008


McPacino wrote:
> I have a network printer. the default paper size is A4.
> I have tried 2 ways to change the paper size:
> 
> 1)
> p = win32print.OpenPrinter(dp)
> t = win32print.GetPrinter(p, 2)
> t['pDevMode'].FormName=u'a3'
> win32print.SetPrinter(p, 2, t, 0)
> 
> these code cause error refuse access, which maybe because of it's network
> printer
> 

The default access for OpenPrinter isn't enough to set the form. Try
win32print.OpenPrinter(dp, {'DesiredAccess':win32print.PRINTER_ALL_ACCESS})

        Roger



More information about the python-win32 mailing list