[CODE=VB]
Private Sub PrintToolStripM enuItem_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles PrintToolStripM enuItem.Click
Try
Dim streamToPrint As StreamReader
Dim printFont As Font
Dim screencapturer As New ScreenshotCaptu re.ScreenCaptur e
Dim randomGenerator As New System.Random(2 000)
Dim filePath As String = Application.Sta rtupPath + "\tempScreenSho ot" + randomGenerator .Next().ToStrin g + ".jpg"
screencapturer. CaptureWindowTo File(Me.Handle, filePath, System.Drawing. Imaging.ImageFo rmat.Jpeg)
streamToPrint = New StreamReader(fi lePath)
printFont = New Font("Arial", 10)
Dim pd As New Printing.PrintD ocument
Dim myDialog As New PrintDialog
myDialog.Docume nt = pd
If myDialog.ShowDi alog() = DialogResult.OK Then
pd.PrinterSetti ngs = myDialog.Printe rSettings
pd.Print()
End If
Dim fileToBeDeleted As New System.IO.FileI nfo(filePath)
fileToBeDeleted .Delete()
Catch ex As Exception
ExceptionManage r.Publish(ex)
End Try
End Sub
[/CODE]
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
Private Sub PrintToolStripM enuItem_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles PrintToolStripM enuItem.Click
Try
Dim streamToPrint As StreamReader
Dim printFont As Font
Dim screencapturer As New ScreenshotCaptu re.ScreenCaptur e
Dim randomGenerator As New System.Random(2 000)
Dim filePath As String = Application.Sta rtupPath + "\tempScreenSho ot" + randomGenerator .Next().ToStrin g + ".jpg"
screencapturer. CaptureWindowTo File(Me.Handle, filePath, System.Drawing. Imaging.ImageFo rmat.Jpeg)
streamToPrint = New StreamReader(fi lePath)
printFont = New Font("Arial", 10)
Dim pd As New Printing.PrintD ocument
Dim myDialog As New PrintDialog
myDialog.Docume nt = pd
If myDialog.ShowDi alog() = DialogResult.OK Then
pd.PrinterSetti ngs = myDialog.Printe rSettings
pd.Print()
End If
Dim fileToBeDeleted As New System.IO.FileI nfo(filePath)
fileToBeDeleted .Delete()
Catch ex As Exception
ExceptionManage r.Publish(ex)
End Try
End Sub
[/CODE]
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
Comment