New to Telerik Reporting? Download free 30-day trial

Generate Barcodes not supported out of the box

Environment

Product Progress® Telerik® Reporting

Description

The Barcode item supports limited number of Barcode Encodings. Here we demonstrate a workaround for generating and displaying Barcodes with unsupported encodings.

Solution

Use PictureBox item with Value set to an image generated by a Custom User Function that uses third party software to generate Barcode as an Image.

For example, you may use IronBarCode library as demonstrated in the code snippet below :

using IronBarCode;
using System.Drawing;

public static class UserFunctions
{
    public static Image GetBarCodeImage(string value, string encoding)
    {
        BarcodeWriterEncoding barcodeEncoding = GetBarCodeEncoding(encoding);

        Image barcodeImage = BarcodeWriter.CreateBarcode(value, barcodeEncoding).Image;

        return barcodeImage;
    }

    private static BarcodeWriterEncoding GetBarCodeEncoding(string encoding)
    {
        // Include logic for selecting Barcode Encoding

        BarcodeWriterEncoding coder;

        switch (encoding)
        {
            case "QRCode":
                coder = BarcodeWriterEncoding.QRCode;
                break;
            case "Data Matrix":
                coder = BarcodeWriterEncoding.DataMatrix;
                break;

           // Include other options if required 

            default:
                throw new System.Exception("Unavailable Barcode Encoder");
        }

        return coder;
    }
}

You may download a sample project including Report, User Function utilizing IronBarCode library (througn NuGet package) and Windows Forms Report Viewer. The barcode from the PictureBox may be seen only through the viewer ran from Visual Studio.

In this article