Search code examples
vb.netwinformsprintdocument

System.Drawing.Printing.PrintDocument without popup printing page 1 of document


we have a windows form application trying to do regular printouts.

Clients are complaining with popup coming up while we do multiple print outs saying printing page 1 of document. ( i guess im not allowed to post pictures, i dont have the reputation, so here is the screenshot)

Is there a way to hide these. or should we be using a different method. Thank you.

Function Print()
    Dim prn As New Printing.PrintDocument
    Using (prn)
        prn.PrinterSettings.PrinterName = sPrnName
        prn.PrinterSettings.Copies = 1
        AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler
        prn.Print()
        RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler
    End Using


End Sub



Private Sub PrintPageHandler(ByVal sender As Object, _
   ByVal args As Printing.PrintPageEventArgs)
    Dim myFont As New Font("Courier New", 9)
    args.Graphics.DrawString(_sPrnRows, _
       New Font(myFont, FontStyle.Bold), _
       Brushes.Black, 5, 5)
End Sub

Solution

  • The answer is from question albert found. prn.PrintController = new System.Drawing.Printing.StandardPrintController()