This is my first Printing of data experience in vb.net:
I need help on how to send DATA/TEXTBOX value to thermal printer.
I am sending the following to thermal printer with 2 font size.
-- Company logo
-- Queuing Number -- font size 55
-- Date and Time -- font size 8
I need an output that woul look like this
-----------------------------------------------
logo
001
Fri, 2 Oct 2015 10:00 AM
-----------------------------------------------
Only the logo and Queuing number is printing and the third row which is the date/time is printing over the logo image.
the script is this:
---------------------------
Thank you for your help!
I need help on how to send DATA/TEXTBOX value to thermal printer.
I am sending the following to thermal printer with 2 font size.
-- Company logo
-- Queuing Number -- font size 55
-- Date and Time -- font size 8
I need an output that woul look like this
-----------------------------------------------
logo
001
Fri, 2 Oct 2015 10:00 AM
-----------------------------------------------
Only the logo and Queuing number is printing and the third row which is the date/time is printing over the logo image.
the script is this:
Private Sub PrintQue_Print(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintQue.PrintPage
Static currentChar As Integer
Dim QFontNum As Font = New Font("Times New Roman", 55, FontStyle.Bold)
Dim DFont As Font = New Font("Times New Roman", 8, FontStyle.Regular)
Dim h, w As Integer
Dim left, top As Integer
With PrintQue.DefaultPageSettings
h = 0
w = 0
left = 0
top = 0.25
End With
'Queuing Number
Dim TextToPrint As String = LblQueNum.Text
Dim LineLen As String = TextToPrint.Length
Dim spcLen As New String(" "c, Math.Round((30 - LineLen)))
Dim lineLevel As Integer = CInt(Math.Round(h / 1))
Dim b As New Rectangle(left, top, w, h)
Dim format As StringFormat
format = New StringFormat(StringFormatFlags.LineLimit)
Dim line, chars As Integer
Dim imgeLocation As Point = New Point(5, 5)
Dim path As String = "D:\Database\Releasing\img\logo-bw2.jpg"
Dim img As Image = Image.FromFile(path)
'Draw the image.
e.Graphics.DrawImage(img, imgeLocation)
e.Graphics.MeasureString(Mid(TextToPrint, currentChar + 1), QFontNum, New SizeF(w, h), format, chars, line)
e.Graphics.DrawString(TextToPrint.Substring(currentChar, chars), QFontNum, Brushes.Black, b, format)
currentChar = currentChar + chars
If currentChar < TextToPrint.Length Then
e.HasMorePages = True
Else
e.HasMorePages = False
currentChar = 0
End If
Dim curDate As Date = Environment.NewLine & DateTime.Now.ToString
Dim StringToPrint As String = curDate.ToString("ddd, dd MMM yyyy") & Environment.NewLine & FormatDateTime(Now().ToString, vbLongTime)
e.Graphics.MeasureString(Mid(StringToPrint, currentChar + 1), DFont, New SizeF(w, h), format, chars, line)
e.Graphics.DrawString(StringToPrint.Substring(currentChar, chars), DFont, Brushes.Black, b, format)
currentChar = currentChar + chars
If currentChar < StringToPrint.Length Then
e.HasMorePages = True
Else
e.HasMorePages = False
currentChar = 0
End If
End Sub
---------------------------
Thank you for your help!
Last edited by a moderator: