How to draw an EAN-13 barcode in Visual C#

5.2k Views Asked by At

What's the most basic way of drawing EAN-13 barcodes in C# (using Visual Studio 2013) for printing?

I would prefer to include a namespace providing me with the tools to create and output the barcode.

1

There are 1 best solutions below

2
On BEST ANSWER

The easiest library to use IMHO is Aspose BarCode.NET. You can find examples here

The library does cost money, but works well enough that for us, it was worth it.

// Create an instance of BarCodeBuilder
BarCodeBuilder builder = new BarCodeBuilder();

// Set the symbology type
builder.SymbologyType = Symbology.EAN13;

// Set the codetext
builder.CodeText = "test-123";

// Get the barcode image
Image img = builder.BarCodeImage;

Now you can do whatever you want with the image, like save it to a file, or write to a memory stream, etc.:

img.Save("path", System.Drawing.Imaging.ImageFormat.Bmp);