Auto print without dialog

后端 未结 3 1730
情话喂你
情话喂你 2020-12-06 03:04

I found code for printing. But I want to sent to printer automaticaly without dialog box. I know printername. I get printer name from SQL table. How can I do it ?



        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 03:38

    Instead of the PrintDialog class, try using the PrintDocument class directly, where you can set the printer by the name:

    using System.Drawing.Printing;
    
    PrintDocument pd = new PrintDocument();
    pd.PrinterSettings.PrinterName = "my printer";
    

    To loop through the available printer names:

    foreach (string s in PrinterSettings.InstalledPrinters) {
      //
    }
    

提交回复
热议问题