2
votes

I have a WPF user control and I want to be able to print it using PrintDialog.PrintVisual(). I don't want to show the print dialog so I want to be able to set a specific printer and printer tray to print it to. I figured out how to print to a specific printer but I need to print to "Tray 3" of my printer and I can't figure out how.

PrintDialog dialog = new PrintDialog();
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue pq = localPrintServer.GetPrintQueue("HC102-HP5SIMXX");
dialog.PrintQueue = pq;
//Set printer tray somehow
dialog.PrintVisual(myControl, "My control");
1
If there is a way to not use the PrintVisual, I'd be interested in that as well.Scott Chantry

1 Answers

1
votes

UPDATE: More info here:

http://social.msdn.microsoft.com/Forums/en-US/windowsxps/thread/f5859148-26f1-4e89-949c-180413bcc898/

http://www.wittersworld.com/selecting-the-input-tray-when-printing-xps-documents/

You have to use the GetPrintcapabilitiesAsXML to be able to get the full list of InputBins.


You can query InputBinCapability on PrintCapabilities to query the available InputBins.

The create a PrintTicket which chooses the tray via InputBin.

Then tell the PrintQueue to use the User ticket via the UserPrintTicket