Generate Barcode – RDLC

In this post we are going to explore how we can generate multi column barcode using rdlc reporting tool. Let’s get started…

Content

  • Install NuGet Package(BarcodeLib)
  • Enable RDLC Reporting in Visual Studio 2019
  • Design RDLC Report for Barcode
  • Generate Barcode

Install NuGet Package

Install-Package BarcodeLib -Version 2.3.0

Enable RDLC Reporting in Visual Studio 2019

Design RDLC Report for Barcode

Next lets set column property

Generate Barcode

Prepare data to show barcode in RDLC by generating barcode image, also it is saving generated file to local folder as .png.

//Encode
Image img = barcode.Encode(BarcodeLib.TYPE.CODE128, sitem.detailsid, Color.Black, Color.Transparent, 635, 105);
using (MemoryStream ms = new MemoryStream())
{
    img.Save(ms, ImageFormat.Png);
    _objData.Add(new vmProductDetails
    {
        detailsid = sitem.detailsid,
        sizename = sitem.sizename,
        offerprice = sitem.offerprice,
        codeimage = ms.ToArray()
    });

    //Save Generated Image
    string tempfolder = @"C:\barcode\";
    if (!Directory.Exists(tempfolder))
        Directory.CreateDirectory(tempfolder);
    string filepath = tempfolder + sitem.detailsid + ".png";
    img.Save(filepath, ImageFormat.Png);

    //Display Generated Image
    barcodeImagePanel.BackgroundImageLayout = ImageLayout.Center;
    var _img = resizeImage(img, new Size(235, 39));
    barcodeImagePanel.BackgroundImage = _img;
}

Finally build and run the application, click generate button to get below generated barcode print layout.

Hope this’ll help 🙂

Download/clone full source code from , Thanks.

Author:

Since March 2011, have 8+ years of professional experience on software development, currently working as Senior Software Engineer at s3 Innovate Pte Ltd.

Leave a Reply