Re: [python-win32] Problem with win32print.SetPrinter

2011-03-01 Thread Tefnet Developers
Dnia 2011-02-28, pon o godzinie 19:11 -0500, Roger Upole pisze:
 I think this is dependent on the printer driver.
 Some use the paper size defined by the the form,
 and others use the PaperSize member.

The driver used is the generic postscript driver (MS Publisher
Imagesetter) provided with Windows.

My problem is that changing paper size in the default printer
preferences UI changes both members of devmode.

Changing the way I do it (as shown before) does not change the paper
size in preferences UI - and that's exactly what I need to change.

I guess that if both fields are affected by the UI then I should also
change both to achieve the desired effect, right?

bye,
Filip Zyzniewski
Tefnet


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem with win32print.SetPrinter

2011-03-01 Thread Roger Upole

Tefnet Developers develop...@tefnet.pl wrote in message 
news:1298974742.7642.1.camel@cacko...
 Dnia 2011-02-28, pon o godzinie 19:11 -0500, Roger Upole pisze:
 I think this is dependent on the printer driver.
 Some use the paper size defined by the the form,
 and others use the PaperSize member.

 The driver used is the generic postscript driver (MS Publisher
 Imagesetter) provided with Windows.

 My problem is that changing paper size in the default printer
 preferences UI changes both members of devmode.

 Changing the way I do it (as shown before) does not change the paper
 size in preferences UI - and that's exactly what I need to change.

 I guess that if both fields are affected by the UI then I should also
 change both to achieve the desired effect, right?

 bye,
 Filip Zyzniewski
 Tefnet


Try adding a second GetPrinter immediately after the SetPrinter,
and see if the returned devmode has the expected values.

Roger





___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem with win32print.SetPrinter

2011-03-01 Thread Tim Roberts
Roger Upole wrote:
 Tefnet Developers develop...@tefnet.pl wrote in message 
 news:1298974742.7642.1.camel@cacko...

 The driver used is the generic postscript driver (MS Publisher
 Imagesetter) provided with Windows.

 My problem is that changing paper size in the default printer
 preferences UI changes both members of devmode.

 Changing the way I do it (as shown before) does not change the paper
 size in preferences UI - and that's exactly what I need to change.

 I guess that if both fields are affected by the UI then I should also
 change both to achieve the desired effect, right?

 bye,
 Filip Zyzniewski
 Tefnet
 Try adding a second GetPrinter immediately after the SetPrinter,
 and see if the returned devmode has the expected values.

This kind of thing is very tricky in Windows -- much trickier than it
should be -- and I've been doing Windows programming for a very, very
long time.  I have a wxPython application that I use to print envelopes
through my Dell 3100 laser printer.  The printer has a multi-purpose
tray that I keep stocked with #10 envelopes.  It's very convenient, and
since my handwriting it terrible, the people I write to appreciate it as
well.

Recently, I upgraded from Python 2.5 to Python 2.7, and suddenly my
envelope application stopped working.  It would print in portrait mode
on the normal paper stock, instead of selecting the envelopes in the
multi-purpose tray.  It required two or three hours of fairly intense
hacking before I figured out a recipe to make it work again.  If I had
not previously been a GDI driver developer, I doubt that I could have
figured out the DEVMODE magic that was required.

-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem with win32print.SetPrinter

2011-02-28 Thread Roger Upole
I think this is dependent on the printer driver.
Some use the paper size defined by the the form,
and others use the PaperSize member.

  Roger

Tefnet Developers develop...@tefnet.pl wrote in message 
news:129553.2645.29.camel@cacko...
 Hi,

 I am adding some printers connection as a user with
 win32print.AddPrinterConnection().

 Afterwards I want to set paper size to A4 (I have no idea why Polish
 Windows XP sets it to Letter by default) with this example code:

 ==
 import win32print
 import win32con
 import win32gui
 import pywintypes

 printer = r'\\drukarki\kp01'

 handle = win32print.OpenPrinter(printer, {'DesiredAccess':
 win32print.PRINTER_ACCESS_USE})

 devmodeSize=win32print.DocumentProperties(0, handle, printer, None,
 None, 0)
 devmode = pywintypes.DEVMODEType(devmodeSize -
 pywintypes.DEVMODEType().Size)
 win32print.DocumentProperties(0, handle, printer, devmode, devmode,
 win32con.DM_IN_BUFFER | win32con.DM_OUT_BUFFER)

 print 'FormName before: %s' % devmode.FormName
 print 'PaperSize before: %s' % devmode.PaperSize

 devmode.FormName = A4
 devmode.PaperSize = win32con.DMPAPER_A4
 devmode.Fields = devmode.Fields | win32con.DM_FORMNAME |
 win32con.DM_PAPERSIZE

 print 'FormName set: %s' % devmode.FormName
 print 'PaperSize set: %s' % devmode.PaperSize

 info = win32print.GetPrinter(handle, 9)
 info[pDevMode] = devmode
 win32print.SetPrinter(handle, 9, info, 0)

 devmodeSize=win32print.DocumentProperties(0, handle, printer, None,
 None, 0)
 devmode = pywintypes.DEVMODEType(devmodeSize -
 pywintypes.DEVMODEType().Size)
 win32print.DocumentProperties(0, handle, printer, devmode, devmode,
 win32con.DM_IN_BUFFER | win32con.DM_OUT_BUFFER)

 print 'FormName after: %s' % devmode.FormName
 print 'PaperSize after: %s' % devmode.PaperSize

 win32print.ClosePrinter(handle)

 win32gui.SendMessageTimeout(win32con.HWND_BROADCAST,
 win32con.WM_DEVMODECHANGE, 0, 0, 0, 2000)
 ==

 The output looks like this:
 ==
 FormName before: A4
 PaperSize before: 1
 FormName set: A4
 PaperSize set: 9
 FormName after: A4
 PaperSize after: 1
 ==

 So, as you can see - FormName changes, but PaperSize does not.
 Am I doing something wrong here? I've spent a lot of time trying to
 solve it, yet came up with nothing.

 Do you have any suggestions?

 Thanks,
 Filip Zyzniewski
 Tefnet 



___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32