How do I suppress the 'Printing' dialog with the Cancel button?

My code is as follows. I would like to suppress the 'printing' dialog that displays with a Cancel button on it.  Thanks!

  Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
 
        Dim bmp As Bitmap = New Bitmap(PriorsMap.Size.Width, PriorsMap.Size.Height)
        Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, PriorsMap.Size.Width, PriorsMap.Size.Height)

        PriorsMap.DrawToBitmap(bmp, rect)
        bmp.Save(Application.StartupPath & "\map.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

         e.Graphics.DrawImage(bmp, PriorsMap.ClientRectangle)

    End Sub
MEINMELAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Those are probably the page settings which need tweaking.
0
 
MEINMELAuthor Commented:
An additional question:
I changed the paper to Landscape and the DrawImage rectangle to e.MarginBounds, and the print out looks much better.  However, it looks crooked. Is there a way to correct this?  Attached is a scanned image.
 Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        ' create the bitmap that will be printed
        Using bmp As Bitmap = New Bitmap(PriorsMap.Size.Width, PriorsMap.Size.Height)

            Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, PriorsMap.Size.Width, PriorsMap.Size.Height)

            PriorsMap.DrawToBitmap(bmp, rect)
            bmp.Save(Application.StartupPath & "\map.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

            e.Graphics.DrawImage(bmp, e.MarginBounds)
        End Using
    End Sub
    Private Sub PrintMap()
        Using pd As New System.Drawing.Printing.PrintDocument
            AddHandler pd.PrintPage, AddressOf OnPrintPage

            ' collapse the panel with the incident list so more of the map will show
            spcDetails.Panel2Collapsed = True
            Application.DoEvents()
            pd.DocumentName = "Prior Calls " & Now

            pd.DefaultPageSettings.Landscape = True
            pd.Print()
            pd.Dispose()

            RemoveHandler pd.PrintPage, AddressOf OnPrintPage
            spcDetails.Panel2Collapsed = False
        End Using
    End Sub

Open in new window

20100401113756.pdf
0
 
CodeCruiserCommented:
Do you mean you want to print directly without going through the print dialog? Show us the code which invokes printing.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
MEINMELAuthor Commented:
No, I just wanted to suppress the window that comes up showing 'printing' and has a cancel button; I have since figured out how:  
pd.PrintController = New System.Drawing.Printing.StandardPrintController .  

I sent the code in my second update, along with a scanned image of the printer output and another question.
0
 
CodeCruiserCommented:
>However, it looks crooked. Is there a way to correct this?

Please explain what you mean.
0
 
MEINMELAuthor Commented:
If you look at the pdf that I attached, the picture of the bitmap looks crooked on the papaer.  I tried a couple of different printers and it always comes out looking like that.  By crooked, I mean the margin size is not straight/the same width.
0
 
MEINMELAuthor Commented:
No example.
0
All Courses

From novice to tech pro — start learning today.