Printing problem

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2007
Posts: 24
Reputation: blondie.simon is an unknown quantity at this point 
Solved Threads: 0
blondie.simon blondie.simon is offline Offline
Newbie Poster

Printing problem

 
0
  #1
Jul 31st, 2007
I have written software that creates a text file, the text file contains colums of data. When I view and print the text file using notepad all the colums line up correctly. I am now trying to print the text file using a button on my form but every time I print it all the colums are no longer lined up :-(

This is the code that I'm using to do the print.

  1. Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
  2.  
  3. Dim LinesPerPage As Single = 0
  4. Dim yPosition As Single = 0
  5. Dim count As Integer = 0
  6. Dim leftMargin As Single = e.MarginBounds.Left
  7. Dim topMargin As Single = e.MarginBounds.Top
  8. Dim strLine As String = Nothing
  9. Dim printFont As Font = Me.lblFadeRate.Font
  10. Dim myBrush As New SolidBrush(Color.Black)
  11.  
  12. 'Work out the number of lines per page, using the MarginBounds.
  13. LinesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)
  14.  
  15. 'Iterate over the string using the StringBuilder, printing each line.
  16. strLine = MyStreamReader.ReadLine
  17. While count < LinesPerPage
  18. 'Calculate the next line position based on the height on the font according
  19. 'to the printing device
  20. yPosition = (topMargin + (count * printFont.GetHeight(e.Graphics)))
  21.  
  22. 'draw the next line in the stream
  23. e.Graphics.DrawString(strLine, printFont, myBrush, leftMargin, yPosition, New StringFormat())
  24. count += 1
  25. strLine = MyStreamReader.ReadLine
  26. End While
  27.  
  28. 'check to see if there is another page left to print
  29. If MyStreamReader.EndOfStream = False Then
  30. e.HasMorePages = True
  31. Else
  32. e.HasMorePages = False
  33. MyStreamReader.Close() 'Close stream reader
  34. End If
  35. End Sub

Am I missing a setting somewhere???


Thanks for any help you can give me

Simon
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,094
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Printing problem

 
0
  #2
Jul 31st, 2007
Are you printing from the same system on which your code resides.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 24
Reputation: blondie.simon is an unknown quantity at this point 
Solved Threads: 0
blondie.simon blondie.simon is offline Offline
Newbie Poster

Re: Printing problem

 
0
  #3
Jul 31st, 2007
Yes
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,094
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Printing problem

 
0
  #4
Jul 31st, 2007
Are you printing from the same system on which your code resides.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,094
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Printing problem

 
0
  #5
Jul 31st, 2007
Are yo sure the printer is not a network printer and the font of notepad is same every where.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Printing problem

 
0
  #6
Jul 31st, 2007
Hi Simon,

make the Font of the NotePad "Courier New", it is a UniDistant font (all fonts acquire same space on screen/media), ur texts will look like Columns..

REgards
Veena
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 24
Reputation: blondie.simon is an unknown quantity at this point 
Solved Threads: 0
blondie.simon blondie.simon is offline Offline
Newbie Poster

Re: Printing problem

 
0
  #7
Jul 31st, 2007
Originally Posted by QVeen72 View Post
Hi Simon,

make the Font of the NotePad "Courier New", it is a UniDistant font (all fonts acquire same space on screen/media), ur texts will look like Columns..

REgards
Veena

Thanks for that It worked a treat
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC