1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
Dim filename As String = IO.Path.Combine(IO.Path.GetTempPath & Date.Now.Ticks.ToString & ".png")
b.Save(filename)
Print.PrintPreviewControl1.Tag = filename
Print.PrintDialog1.Document = Print.PrintDocument1
Print.ShowDialog()
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
PrintDialog1.ShowDialog()
PrintDocument1.Print()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub PrintDocument1_EndPrint(sender As Object, e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.EndPrint
Try
IO.File.Delete(PrintDocument1.DocumentName)
Catch ex As Exception
End Try
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(Image.FromFile(PrintPreviewControl1.Tag), New Point(0, 0))
e.PageSettings.Landscape = True
End Sub
Private Sub PrintPreviewControl1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles PrintPreviewControl1.Paint
e.Graphics.DrawImage(Image.FromFile(PrintPreviewControl1.Tag), New Point(0, 0))
End Sub |