Connecting Tech Pros Worldwide Forums | Help | Site Map

print the jpeg file using screencapture dll in vb.net

Newbie
 
Join Date: Nov 2008
Posts: 5
#1: Nov 20 '08
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
  3.  
  4. Try
  5.  
  6. Dim streamToPrint As StreamReader
  7.  
  8. Dim printFont As Font
  9.  
  10. Dim screencapturer As New ScreenshotCapture.ScreenCapture
  11.  
  12. Dim randomGenerator As New System.Random(2000)
  13.  
  14. Dim filePath As String = Application.StartupPath + "\tempScreenShoot" + randomGenerator.Next().ToString + ".jpg"
  15.  
  16. screencapturer.CaptureWindowToFile(Me.Handle, filePath, System.Drawing.Imaging.ImageFormat.Jpeg)
  17.  
  18. streamToPrint = New StreamReader(filePath)
  19.  
  20. printFont = New Font("Arial", 10)
  21.  
  22. Dim pd As New Printing.PrintDocument
  23.  
  24. Dim myDialog As New PrintDialog
  25.  
  26. myDialog.Document = pd
  27.  
  28. If myDialog.ShowDialog() = DialogResult.OK Then
  29.  
  30. pd.PrinterSettings = myDialog.PrinterSettings
  31.  
  32. pd.Print()
  33.  
  34. End If
  35.  
  36. Dim fileToBeDeleted As New System.IO.FileInfo(filePath)
  37.  
  38. fileToBeDeleted.Delete()
  39.  
  40. Catch ex As Exception
  41.  
  42. ExceptionManager.Publish(ex)
  43.  
  44. End Try
  45.  
  46. End Sub
  47.  

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

Dököll's Avatar
Moderator
 
Join Date: Nov 2006
Location: Upstate NY - US
Posts: 2,268
#2: Nov 24 '08

re: print the jpeg file using screencapture dll in vb.net


Hello Hello!

I added a couple of code tags for you, sending over to .NET for ya, for a closer look.

Hope this helps!
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,608
#3: Dec 6 '08

re: print the jpeg file using screencapture dll in vb.net


Moved to Answers instead of Insights.
Reply