I am having a ListBox where I show all the printer I can find on the windows client.
List<MyPrinterClass> lstPrinters = new List<MyPrinterClass>();
foreach (var item in PrinterSettings.InstalledPrinters)
{
MyPrinterClass d = new MyPrinterClass();
d.printerName = item.ToString();
lstPrinters.Add(d);
}
If needed my class so far
public class MyPrinterClass
{
public string imageSource { get; set; }
public Bitmap imageBmp { get; set; }
public string printerName { get; set; }
public List<PaperSource> paperSources { get; set; }
}
I am trying to get the trays and if possible (by the printer) the containing paperSource. The printers have to be installed on the client (its a given condition to my solution). So the details of trays and paperSource should be known by Windows.
What I tried: By PrinterSettings.InstalledPrinters I am able to get the printerNames but there seems to be no access to other data. by PrinterSettings.PaperSources I am able to receive the PaperSources but I am coming from a PrintDocument. So the data isnt related to the selected installed printer from my ListBox.
What I expected: A printer class similar to the universal windows solution given by the MS Guides.
What I could do: I could create a universal windows solution and hand over the data but its my least favorite option to do so.
I recommend to use the WPF library (
System.Printing) instead of the Winforms library (System.Drawing.Printing).Use the
PrintCapabilitiesandPrintQueueto inspect the defaults or to get the current print job in order to get/set the current job's settings via thePrintTicket(e.g. page size, copy count etc.).Use the
LocalPrintServerconstructor overload in case you want to configure a printer.Use
PrintServerto access a remote printer.