This project has moved and is read-only. For the latest updates, please go here.

RDLC Report

Topics: Code 11, Code 128, Code 39, Code 93, Code EAN 13, Code EAN 8
Jan 15, 2010 at 12:49 PM

Is there some way to use this tool on a RDLC report?


Jan 20, 2010 at 12:26 PM

I found a solution:

We added a reference to the project Zen.Barcode.Core.dll library. With this code, we generate an image and convert to an array of bytes.

public byte[] creabarcode(String barcode)
        BarcodeMetrics tamccbb = new BarcodeMetrics(2, 90);
        System.Drawing.Image imagen;

        imagen = BarcodeDrawFactory.GetSymbology(BarcodeSymbology.Code128).Draw(barcode, tamccbb);

        ImageFormat format = ImageFormat.Bmp;

        MemoryStream mm = new MemoryStream();
        imagen.Save(mm, format);
        byte[] bytearray = mm.ToArray();

        return bytearray;

In the datatable we use to load the report add a barcode field of type System.Byte [] (we must add by hand, as it does not appear as default)

Insert a picture in the report. Data attach the properties of the image:

MYMEType: image / bmp
Source: DataBase
Value: = Fields! Barcode.value

I hope this helps.

A greeting

Jun 22, 2015 at 10:34 AM
Thanks @jmgarica. I too wanted to print the barcode to a pdf generated by RDLC through MVC5.
With your solution I was able to do that though my values did not come from a database.
//Create the barcode image as a bmp file in Images/Temp directory. RDLC will print it from there
using (System.Drawing.Image imagen = BarcodeDrawFactory.GetSymbology(BarcodeSymbology.Code39NC).Draw("123456", 70, 2))
     System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Bmp;
     using (MemoryStream mm = new MemoryStream())
            imagen.Save(mm, format);
            byte[] bytearray = mm.ToArray();
            using (var fs = new BinaryWriter(new FileStream(System.Web.HttpContext.Current.Server.MapPath("~/Images/Temp/") +  "123456.bmp", FileMode.Append, FileAccess.Write)))
Now I simply create a report parameter
string barcodePicture = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + "/Images/Temp/"  + "123456.bmp";
localReport.SetParameters(new ReportParameter("LogoBarcode", barcodePicture));
Thanks @dementeddevil for creating this wonderful utility.