I am developing a full screen kiosk application using c#. I need to print tickets and receipts. I use the PrintDocument class for the printing. Printer prints perfectly, but i need to disable the开发者_JAVA技巧 pop-up dialog shown during printing.
I heard it can be disabled with Printers and Faxes in control panel, but i do not have Printers and Faxes in control panel.
Can i disable the dialog shown? If i could, how can i do it?
I believe setting your PrintDocument
's PrintController
to StandardPrintController
should solve this.
PrintDocument printDocument = new PrintDocument();
PrintController printController = new StandardPrintController();
printDocument.PrintController = printController;
Hope this helps some.
Great question and answer. Here is the VB.Net version googling for vb.net wasn't returning any meaningful results.
Dim printDocument As New System.Drawing.Printing.PrintDocument
Dim printController As New System.Drawing.Printing.StandardPrintController
printDocument.PrintController = printController
Windows 10, 8, 7, & Server 2012 Note: This option is not available in the Home versions of Windows.
Press and hold the Windows Key, then press “R” to bring up the Windows Run dialog box. Type “printmanagement.msc“, then press “Enter“. Expand “Printer Servers“, then right click the name of the computer and select “Printer Server Properties“. Select the “Advanced” tab. Uncheck “Show Informational Notifications for Local Printers” and “Show Informational Notifications for Network Printers“.
This Worked for me. You can try this
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);
}
精彩评论