SoFunction
Updated on 2025-03-01

Simple way to generate barcode images in C#

This article examples illustrate the simple method of generating barcode images in C#. Share it for your reference. The specific implementation method is as follows:

Implementation principle:

In fact, Windows itself has a font used to display barcodes.
Just change the number to this font and it becomes a barcode.

Under the Windows Font Library, there are eight fonts that can be used to convert numbers into barcodes:
Code39AzaleaNarrow1
Code39AzaleaNarrow2
Code39AzaleaNarrow3
Code39AzaleaRegular1
Code39AzaleaRegular2
Code39AzaleaWide1
Code39AzaleaWide2
Code39AzaleaWide3

Post the code for your reference:

Copy the codeThe code is as follows:
Bitmap b=new Bitmap(200,200);
Graphics g = (b);
Font font = new Font("Code39AzaleaRegular2", 32);
("123456", font, , new PointF(100,100)); 
= b;
=

I hope this article will be helpful to everyone's C# programming.