我相信将你的PrintDocument
的PrintController
设置为StandardPrintController
应该可以解决这个问题。
PrintDocument printDocument = new PrintDocument();
PrintController printController = new StandardPrintController();
printDocument.PrintController = printController;
希望这有所帮助。
好问题和答案。这里是VB.Net版本,搜索vb.net没有返回任何有意义的结果。
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 注意:此选项不适用于Windows Home版本。
按住Windows键,然后按“R”键打开Windows运行对话框。 输入“printmanagement.msc”,然后按“Enter”键。 展开“打印机服务器”,然后右键单击计算机名称并选择“打印机服务器属性”。 选择“高级”选项卡。 取消选中“显示本地打印机的信息通知”和“显示网络打印机的信息通知”。
这对我有用。你也可以尝试一下
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);
}