So I have an Window which I want to Print. For that I created an Print Dialog. Which looks like that:
PrinterSettings settings = new PrinterSettings();
string Printer = settings.PrinterName;
System.Windows.Controls.PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
printDlg.PrintQueue = new PrintQueue(new PrintServer(), Printer);
printDlg.PrintTicket.CopyCount = 1;
printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;
printDlg.PrintVisual(this, "Window Printing.");
But for some reason it opens instant an Dialog for save that Programm as PDF. But I want directly print it to my Printer, without that Dialog. So why does it not Print to my Printer? And how Can I get this to work.
Are you sure you have chosen the correct printer? Because the
PrintDialogwill behave like this if its printer is set to a file printer, for example to:"Microsoft Print to PDF". (Then, obviously, you have to provide the name of the file the printer should print to, hence the "save" dialog.)Check what printers you have installed (or rather, what
PrintQueuesyou have available):Are you sure you're setting one of those? Which one is the default in your system? Is it maybe a file printer?
Try setting a printer name to the correct, physical printer in code, and check if anything will print:
In the system, is the printer configured correctly?