I want a simple barcode generator library for C# that is open source and free. It should support popular barcode types like Code 128.

It is very important that it be open source, and should be in C#. The generated image should have the barcode with text below it.

I used iTextSharp but didn't get the result I wanted.

2 Answers 2


I used the ZXing C# port with great success in my last project.

ZXing Codeplex page

One issue I found though was that when decoding the barcodes if the picture was too large it would not find the barcode.

This might not be an issue for you if you are just using the generation part of the library.

I used this function to shrink the picture if it was too large:

public Image scaleImage(Image image, int maxWidth, int maxHeight)
    var ratioX = (double)maxWidth / image.Width;
    var ratioY = (double)maxHeight / image.Height;
    var ratio = Math.Min(ratioX, ratioY);

    var newWidth = (int)(image.Width * ratio);
    var newHeight = (int)(image.Height * ratio);

    var newImage = new Bitmap(newWidth, newHeight);
    Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
    return newImage;
  • thanks. it solved my problem. but have a little question too. does it have a color option that I can change the color of barcode? Commented Jul 18, 2015 at 10:01
  • I only made use of the barcode decoding parts of the library so I did not look closely at the barcode generation portion. Commented Jul 20, 2015 at 15:55

We've used barcodelibrary and were happy with the results. You can find the source on google and a nice article on codeproject. It has numerous outputs and will optionally put text below the barcode in a number of formats and positions.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.