Imports System.Drawing
Imports System.IO
Public Class testprint
Function createBarCodeSimple(ByVal info As String) As Drawing.Bitmap
Dim k As String = info
Dim stchar As String = String.Empty
Dim addStar As String = "*"
Dim full As String = addStar & info & addStar
info = full
Dim bc As Drawing.Bitmap = New Drawing.Bitmap(1, 1)
'Dim myf As Font = New Font("Arial", 12, FontStyle.Regular) ', GraphicsUnit.Point)
Dim ft As Drawing.Font = New Drawing.Font("Free 3 of 9 Extended", 25, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Point)
Dim g As Drawing.Graphics = Drawing.Graphics.FromImage(bc)
Dim infoSize As Drawing.SizeF = g.MeasureString(info, ft)
bc = New Drawing.Bitmap(bc, infoSize.ToSize)
g = Drawing.Graphics.FromImage(bc)
g.Clear(Drawing.Color.White)
g.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixel '
For Each chr As Char In info
stchar &= chr.ToString & " "
Next
g.DrawString(stchar, ft, New Drawing.SolidBrush(Drawing.Color.Black), 2, 3)
g.Flush()
ft.Dispose()
g.Dispose()
Return bc
End Function
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(createBarCodeSimple("*creaSi123mple*"), 0, 0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
End Class