So, I've wrote a program awhile ago that prints barcode labels. The old version needed the font to be installed in the fonts folder, but that made it a pain for people using the program for the first time, as the program would print the barcode label with a default font. If I load the font file directly and try and print, it just shows up with the default font, obviously not a barcode. The following doesn't seem to work:

Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        Dim pointF As New PointF(0, 0)

        Dim drawFormat As New StringFormat
        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

        Dim drawBrush As New SolidBrush(Color.Black)

        ' Install and size the font
        Dim barcodeFont As Font
        Dim barcodeFontSize = 36
        Dim pfc As New PrivateFontCollection
        pfc.AddFontFile("FRE3OF9X.TTF")
        barcodeFont = New Font(pfc.Families(0), barcodeFontSize)
        e.Graphics.DrawString(serial, barcodeFont, drawBrush, pointF, drawFormat)

        ' There are no more pages.
        e.HasMorePages = False
    End Sub

This is the old way, and it does work:

Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        Dim pointF As New PointF(0, 0)

        Dim drawFormat As New StringFormat
        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

        Dim drawBrush As New SolidBrush(Color.Black)

        ' Install and size the font
        Dim barcodeFont As Font
        Dim barcodeFontSize = 36
        barcodeFont = New Font("Free 3 of 9 Extended", barcodeFontSize)
        e.Graphics.DrawString(serial, barcodeFont, drawBrush, pointF, drawFormat)

        ' There are no more pages.
        e.HasMorePages = False
    End Sub

I've loaded this font into a font family and successfully printed a barcode text onto a picture box. For some reason the same process doesn't work here. I was thinking of creating a bitmap and then printing the bitmap, but that seems very round-a-bout.

According to this paper, a printer (of any kind) does not automatically support printing of barcodes by the use of a font.
It seems like it would be less of a hazzle to go the bitmap way, and print an image instead of a text.

According to this paper, a printer (of any kind) does not automatically support printing of barcodes by the use of a font.

This printer has been printing from a software loaded font for about three years now. The document seems to be referring to a hardware loaded font, something which I haven't messed with since my Dot-Matrix printer became old-hat. Although this doesn't really pertain to this situation, I appreciate the response.

My apologies, beyond that I cannot help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.