Printer issue

Hi,

I've got a little problem here. I think I can't be alone with this, so I
thought I'd ask.
My program uses reportlab to generate arbitrary pdf documents (sometimes up to
200 pages). I now want to spool those documents to user selectable printers.
Basically my app provides the choice to select "server printing", which means
the linux server handles the print via a load shared printer installation.
This is no problem. Problematic is client side printing.
The client part usually runs on windows, where is no such thing like "simply
spool it to lpr". Therefor I'd have to get a list of printers in order to
tell my pdf-print-script where to print it to.
But how do I get a list of printers on win32 ? The wxPrintxxx stuff is pretty
useless for this - at least I couldn't figure out how to get a selected
printer from it.
I think the only way to print is to go to the default printer using one of the
DDE scripts which can be found elsewhere on the net. Maybe there is a way to
select a different default printer.

If anyone has some experience with printing not wx generated documents please
give me a hint.

TIA

  UC

···

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

But how do I get a list of printers on win32 ? The wxPrintxxx stuff is
pretty useless for this - at least I couldn't figure out how to get a
selected printer from it.

I get the name of the user-selected printer, together with an optional
range of pages and number of copies, from wx.PrintDialog using
wx.PrintData and wx.PrintDialogData. From this I build a GhostScript
command that goes away and does the printing. Maybe you can pass something
similar to your own pdf-print script - see example code below.

Regards,

David Hughes
Forestfield Software Ltd
www.forestfield.co.uk

#---------Example code - will probably line-wrap ----------------

class dpPrintPdf:
    """ Print the pdf file called pathname containing numpages pages.
        Call the printer setup dialog first using wx.PrintDialog and pass
        selections, including printer name, to Ghostscript so that setup
        doesn't get called again. If setup is called within script it
        doesn't repaint screen properly if it is moved and doesn't obey
        any selections of pages to be printed
    """
    def __init__(self, pathname, numpages):
        pd = wx.PrintData()
        pdd = wx.PrintDialogData()
        pdd.SetPrintData(pd)
        pdd.SetMinPage(1)
        pdd.SetFromPage(1)
        pdd.SetMaxPage(numpages)
        pdd.SetToPage(numpages)
        pdd.EnablePageNumbers(1)
        printerDialog = wx.PrintDialog(apl.mainwin, pdd)
        printerDialog.GetPrintDialogData().SetSetupDialog(False)
        status = printerDialog.ShowModal()
        if status == wx.ID_OK:
            pdd = printerDialog.GetPrintDialogData()
            pd = pdd.GetPrintData()
            printer = pd.GetPrinterName()
            numcopies = pdd.GetNoCopies()
               # GetAllPages() always returns True so use
               # from/to pages regardless of radio-box selection
            frompage = pdd.GetFromPage()
            topage = pdd.GetToPage()
            device = 'mswinpr2'
            sys = apl.sys
            command = (sys.path['gs'] +
                         ' -I' + sys.path['gs_lib'] + ';' +
sys.path['gs_fonts'] +
                         ' -q -dSAFER -dBATCH -dNOPAUSE -dNoCancel ' +
                         ' -dFirstPage=%d -dLastPage=%d ' +
                         ' -sDEVICE=%s -sOutputFile="\\\\spool\%s" '+
                         ' %s') % (frompage, topage, device, printer,
pathname)
            wx.CallAfter(self.DoPrinting, command, numcopies)
        printerDialog.Destroy()

    def DoPrinting(self, command, numcopies):
        " Perform printing after dialog destroyed and main window
repainted"
        wx.BeginBusyCursor()
        for n in range(numcopies):
            os.system(command)
        wx.EndBusyCursor()

#-----------End------------------------------------------

Hi,

Does anyone know if there is a version of wxpython for python 2.0.?

regards,
Stephan