Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

PrintTicket not reflecting Printing Preferences

$
0
0

In Windows 7, if I open the Printer Properties via Devices and Printers, I can set both the Printing Preferences (General tab) and the Printing Defaults (Advanced tab). When I create a WPF PrintDialog the PrintDialog.PrintQueue is set to the default printer and both the PrintDialog.PrintTicket and the PrintDialog.PrintQueue.UserPrintTicket seem to reflect the Printing Preferences, whereas the PrintDialog.PrintQueue.DefaultPrintTicket reflects the Printing Defaults. All fine so far.

When I call PrintDialog.ShowDialog() and select another than the default printer and close the window, my PrintDialog object returns with the correct settings: the Printing Preferences stored in PrintDialog.PrintTicket and PrintDialog.PrintQueue.UserPrintTicket and the Printing Defaults in PrintDialog.PrintQueue.DefaultPrintTicket. Still all fine.

Now, if instead of showing the print dialog, I set the PrintDialog.PrintQueue to another printer in code, like shown below 

    objPrintDialog.PrintQueue = cedPrinting.GetPrintQueue(PrinterName)

    Public Function GetPrintQueue(ByVal strPrinterName As String) As PrintQueue
        For Each objPrintQueue As PrintQueue In GetPrintQueues()
            If objPrintQueue.FullName = strPrinterName Then
                Return objPrintQueue
            End If
        Next

        Return (New LocalPrintServer).DefaultPrintQueue
    End Function

    Public Function GetPrintQueues() As PrintQueueCollection
        Dim objServer As New LocalPrintServer
        Dim aenmTypes As EnumeratedPrintQueueTypes() = {EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections}

        Return objServer.GetPrintQueues(aenmTypes)
    End Function

the PrintDialog.PrintQueue.UserPrintTicket property is set to the Printing Defaults of the new printer, as is the PrintDialog.PrintQueue.DefaultPrintTicket. The PrintDialog.PrintTicket remains unchanged. I cannot find a way to set the PrintTicket to the correct Printing Preferences in a correct way, as I do not have access to them via the PrintDialog. Effectively, I do not know how to mimic in code the action of selecting another print queue in the print dialog. Any help would be appreciated.

I tested this with a Canon MG3100 series Printer, making sure that the Printer Paper Size and the Duplex Printing setting were different for the Printing Preferences and the Printing Defaults.

thanks,
Rutger.


Rutger Koperdraad.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>