如何在win form应用程序中将9条码的代码3打印到普通打印机

时间:2016-02-16 07:42:32

标签: vb.net printing barcode barcode-printing

我想从我的vb.net aplication到打印机打印9条码的代码3。 我想检查是否打印到正确的格式。
我在打印按钮单击中调用此功能,如何将此值传递给我的普通打印机,我只想打印此A4纸

Dim PrinterName As String
Dim Printlabel As New MyPrinter
PrinterName = "Sharp AR-M318 PCL 6"
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", 60, 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
        Printlabel.prt(bc, PrinterName)

1 个答案:

答案 0 :(得分:0)

我建议你使用Zen Barcode。这样更容易处理,并且您并不认为该字体安装在运行软件的PC上。此外,您不必打扰校验和。

您可以在这里找到nuget-package:https://www.nuget.org/packages/Zen.Barcode.Rendering.Framework/