33

我正在使用 c# 开发一个全屏信息亭应用程序。我需要打印门票和收据。我使用 PrintDocument 类进行打印。打印机打印完美,但我需要禁用打印过程中显示的弹出对话框。

截屏

我听说可以在控制面板中使用打印机和传真禁用它,但我在控制面板中没有打印机和传真。

我可以禁用显示的对话框吗?如果可以,我该怎么做?

4

4 回答 4

64

我相信设置你PrintDocument的 'sPrintController应该StandardPrintController可以解决这个问题。

PrintDocument printDocument = new PrintDocument();
PrintController printController = new StandardPrintController();
printDocument.PrintController = printController;

希望这会有所帮助。

于 2011-04-01T10:05:10.053 回答
5

很好的问答。这是用于 vb.net 的 VB.Net 版本谷歌搜索没有返回任何有意义的结果。

  Dim printDocument As New System.Drawing.Printing.PrintDocument
  Dim printController As New System.Drawing.Printing.StandardPrintController
  printDocument.PrintController = printController
于 2012-03-05T07:50:06.917 回答
1

Windows 10、8、7 和 Server 2012 注意:此选项在 Windows 的家庭版中不可用。

按住 Windows 键,然后按“R”打开 Windows 运行对话框。输入“printmanagement.msc”,然后按“Enter”。展开“打印机服务器”,然后右键单击计算机名称并选择“打印机服务器属性”。选择“高级”选项卡。取消选中“显示本地打印机的信息通知”和“显示网络打印机的信息通知”。

于 2018-01-10T20:09:40.387 回答
0

这对我有用。你可以试试这个

PrintDocument document = new PrintDocument();
        PrintDialog dialog = new PrintDialog();
        PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
        private  Font printFont;
        private string stringToPrint;
      //  private int linesPerPage=9;
        private Font printFont1;
        QRCode qrCode1;
        private string stringToPrint1;
        private string databasePath;
        int i=1;
        public Form1()
        {
            InitializeComponent();


            //document.DefaultPageSettings.PrinterSettings.PrinterName = "GODEX500";
            //  document.DefaultPageSettings.Landscape = true;
            document.DefaultPageSettings.PaperSize = new PaperSize("75 x50 mm", 300, 200);
            document.DefaultPageSettings.Margins = new Margins(1, 1, 1, 1);
            printFont = new Font("Arial", 10);
            // printFont1 = new Font("NewBarcodeFont", 12);

            //    document= new Font("GODEX-NewBarcodeFont", 12, FontStyle.Regular);
            // document.OriginAtMargins = true;
            //This PrintController worked fine and not showing printing this document using window
            PrintController printController = new StandardPrintController();
            document.PrintController = printController;
            document.PrintPage += new PrintPageEventHandler(document_PrintPage);

        }
于 2018-11-13T10:36:49.070 回答