|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Saturday, December 03, 2011 10:08 AM
Points: 769,
Visits: 187
|
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Saturday, December 03, 2011 10:08 AM
Points: 769,
Visits: 187
|
|
| I have noticed a major flaw in this code. It prints great when using the Tahoma font, but anything else seems to really mess it up.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Saturday, December 03, 2011 10:08 AM
Points: 769,
Visits: 187
|
|
Ok, I have found the problem. Apparently Microsoft has a bug in their e.Graphics.MeasureString function. To remidy this re-organize the primary if block like this: If Asc(smallArray(0, x).Chars(0)) < 30 Then ' make sure to dispose of odd char's in the array' See if any characters will fit.ElseIf characters_fitted > 0 And xmin < (e.MarginBounds.Right - 5) ThenNotice that I switched the if and elseif lines, that is because I was occasionally printing out a graphical representation for the char(0).
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Saturday, December 03, 2011 10:08 AM
Points: 769,
Visits: 187
|
|
Another update, I have perfected the variable character spacing problem when the font size and type changed. Add the following line somewhere above The 'Static i As Integer' line: ' Prepare the fixed spacing for each character Dim fixedSpace As SizeF = e.Graphics.MeasureString("W", the_font)Then replace the following line: ' Increase the location where we can start. xmin += CInt(text_size.Width) - 4 with: ' Increase the location where we can start. xmin += CInt(text_size.Width) - (fixedSpace.Width * 0.25)
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:03 AM
Points: 6,861,
Visits: 8,048
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, April 07, 2011 9:14 PM
Points: 10,
Visits: 22
|
|
Hi Jereme Thanks for this nice piece of work! I have tried to get it to work in ASP.NET 1.1 (vb) but get a run time error "No printers installed." I do have a deault printer but it is a network printer and not on LPT1. Any ideas? Many Thanks Howard Rybko
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Saturday, December 03, 2011 10:08 AM
Points: 769,
Visits: 187
|
|
| Hi Howard, that is my fault for not giving you all the code to properly initialize the class. Try the following: ' Create object, passing in text Dim MyPrintObject As New TextPrint("<B>this will be bold</B>" + vbCrLf + "<ST=400>this will start at 400 pixels", "MyPrinterName")
Also modify the printing class itself to accept two parameters: ' New constructor Public Sub New(ByVal Text As String, ByVal pName As String) ' Sets the file stream MyBase.New() varStart = 0 strText = Text MyBase.PrinterSettings.PrinterName = pName ' This is the key line for setting the printer MySplitLine = strText.Split(vbCrLf) End SubI too use exclusively network printers not local LPT1 ports.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Saturday, December 03, 2011 10:08 AM
Points: 769,
Visits: 187
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, June 15, 2007 6:08 PM
Points: 6,
Visits: 1
|
|
I've not tried your code, but I just want to say thank you for sharing your hardwork with everyone. It's very generous of you.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 04, 2009 2:56 PM
Points: 8,
Visits: 12
|
|
Thanks for sharing. It is very generous of you.
|
|
|
|