kapil.tandon 0 Newbie Poster

Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click

Try

Dim streamToPrint As StreamReader

Dim printFont As Font

Dim screencapturer As New ScreenshotCapture.ScreenCapture

Dim randomGenerator As New System.Random(2000)

Dim filePath As String = Application.StartupPath + "\tempScreenShoot" + randomGenerator.Next().ToString + ".jpg"

screencapturer.CaptureWindowToFile(Me.Handle, filePath, System.Drawing.Imaging.ImageFormat.Jpeg)

streamToPrint = New StreamReader(filePath)

printFont = New Font("Arial", 10)

Dim pd As New Printing.PrintDocument

Dim myDialog As New PrintDialog

myDialog.Document = pd

If myDialog.ShowDialog() = DialogResult.OK Then

pd.PrinterSettings = myDialog.PrinterSettings

pd.Print()

End If

Dim fileToBeDeleted As New System.IO.FileInfo(filePath)

fileToBeDeleted.Delete()

Catch ex As Exception

ExceptionManager.Publish(ex)

End Try

End Sub

this id the code i created for ptinting.it is creating jpg file and then finally printing.i am not able to figure out why it is printing the blank page.

can anybody tell me what is the problem in the code?

n hw can i achieve this task