I have a couple of questions about the PrintDialog and PageSetupDialog and the corresponding PrintData objects that can be retrieved from them. I have a need to retrieve the DevMode for a printer configuration and store it for later use by a C++ Service. A developer who’s hasn’t been with our company for several years “gave up” on this problem before he left and opted for an approach where he launched a printer_setup dialog in a c++ dll, and then called into this dll with ctypes. While I could reuse this approach, I don’t think it should be necessary to do so, and we’d rather not have to maintain the c++ dll in addition to our wxPython project for printer configuration.
Does anyone out there know if there’s a way to access the full, raw devmode from a PrinterDialog or PageSetup dialog? I’ve found member functions to retrieve individual pieces of it via GetPrintData(), GetOrientation(), etc, as well as a GetPrivData() method on the PrintData Object itself, but none of these seem to contain the full devmode, only parts of it. Is what I’m trying to do possible, or am I better off to baby-sit the dll that is able to access the full devmode?
Does printData.GetPrivData() give you what you need? I'm not sure if the DevMod is in that data block, but it might be. There is a native print data class that on Windows gives access to the DevMode, but that class is MSW-only and is not part of the public API.
···
On 9/15/11 10:37 AM, Daniel Casper wrote:
I have a couple of questions about the PrintDialog and PageSetupDialog
and the corresponding PrintData objects that can be retrieved from
them. I have a need to retrieve the DevMode for a printer configuration
and store it for later use by a C++ Service. A developer who's hasn't
been with our company for several years "gave up" on this problem before
he left and opted for an approach where he launched a printer_setup
dialog in a c++ dll, and then called into this dll with ctypes. While I
could reuse this approach, I don't think it should be necessary to do
so, and we'd rather not have to maintain the c++ dll in addition to our
wxPython project for printer configuration.
Does anyone out there know if there's a way to access the full, raw
devmode from a PrinterDialog or PageSetup dialog? I've found member
functions to retrieve individual pieces of it via GetPrintData(),
GetOrientation(), etc, as well as a GetPrivData() method on the
PrintData Object itself, but none of these seem to contain the full
devmode, only parts of it. Is what I'm trying to do possible, or am I
better off to baby-sit the dll that is able to access the full devmode?
res = win32print.DocumentProperties(window, handle, name, dmout, dmin,
mode)
if res == 1:
print dmout.DriverData
2:
dlg = wx.PrintDialog(self)
res = dlg.ShowModal()
if res == wx.ID_OK:
print dlg.GetPrintDialogData().PrintData.GetPrivData()
As far as I can tell the binary structure these two approaches return
is identical. I'm currently testing whether or not this is usable by
our C++ Service. I've hit a new snag though - if I modify the printer
properties using one of these dialogs, and store the binary devmode,
I'm unable to use the binary devmode to re-open the dialog later using
the stored state. IE, if I set Landscape Orientation, then attempt to
re-open the printer dialog using the stored devmode, the printer
dialog does not display that it was configured for Landscape. This is
problematic in that the appearance is that we're failing to store
these printer configurations. Does anyone know if a method or
approach for re-opening one of these dialogs using the binary DevMode
and having it properly display the selected properties based on it?
···
On Sep 15, 11:37 am, Daniel Casper <dancas...@gmail.com> wrote:
I have a couple of questions about the PrintDialog and PageSetupDialog and
the corresponding PrintData objects that can be retrieved from them. I have
a need to retrieve the DevMode for a printer configuration and store it for
later use by a C++ Service. A developer who's hasn't been with our company
for several years "gave up" on this problem before he left and opted for an
approach where he launched a printer_setup dialog in a c++ dll, and then
called into this dll with ctypes. While I could reuse this approach, I
don't think it should be necessary to do so, and we'd rather not have to
maintain the c++ dll in addition to our wxPython project for printer
configuration.
Does anyone out there know if there's a way to access the full, raw devmode
from a PrinterDialog or PageSetup dialog? I've found member functions to
retrieve individual pieces of it via GetPrintData(), GetOrientation(), etc,
as well as a GetPrivData() method on the PrintData Object itself, but none
of these seem to contain the full devmode, only parts of it. Is what I'm
trying to do possible, or am I better off to baby-sit the dll that is able
to access the full devmode?
res = win32print.DocumentProperties(window, handle, name, dmout, dmin,
mode)
if res == 1:
print dmout.DriverData
2:
dlg = wx.PrintDialog(self)
res = dlg.ShowModal()
if res == wx.ID_OK:
print dlg.GetPrintDialogData().PrintData.GetPrivData()
As far as I can tell the binary structure these two approaches return
is identical. I'm currently testing whether or not this is usable by
our C++ Service. I've hit a new snag though - if I modify the printer
properties using one of these dialogs, and store the binary devmode,
I'm unable to use the binary devmode to re-open the dialog later using
the stored state. IE, if I set Landscape Orientation, then attempt to
re-open the printer dialog using the stored devmode, the printer
dialog does not display that it was configured for Landscape. This is
problematic in that the appearance is that we're failing to store
these printer configurations. Does anyone know if a method or
approach for re-opening one of these dialogs using the binary DevMode
and having it properly display the selected properties based on it?