Print redirection

Michael Hipp wrote:

Seems like this would be simple. I'm trying to programmatically redirect print to a different hardcoded printer.

        prt = r'\\front2\HP LaserJet 1022n'
        copies = 2
        printout = wx.html.HtmlPrintout()
        printout.SetHtmlText(html)
        data = wx.PrintDialogData()
        data.GetPrintData().SetNoCopies(copies)
        data.GetPrintData().SetPrinterName(prt)
        printer = wx.Printer(data)
        result = printer.Print(None, printout, False)
        err = printer.GetLastError()

It's always returning False in 'result'. And it takes a long time to return the 'result'. I'm certain the 'prt' string is correct. (Or is there some way to get a list of the valid printers?)

Oddly enough 'err' ends up being 0 (wx.PRINTER_NO_ERROR).

The printout appears to be going nowhere. What (embarrassingly simple thing) am I missing?

Is there an item in the Control Panel/Printers for this printer? If so try using the name as displayed in the control panel rather than the UNC name.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!