How to Generate Barcodes in RDLC ReportsHow to Encode and Print Linear and Matrix Barcode Images for RDLC Reports
- Strong-named assemblies compiled with C#.NET for barcode creation
- Perfectly compatible with Microsoft Visual Studio 2005, 2008 and 2010
- Provide C# and VB sample codes for users to draw barcodes in RDLC Reports
- Support creating linear barcodes for RDLC Reports, like Code 39, EAN-13, UPC-A, etc
- Easy to generate, display 2D barcode types including QR Code, Data Matrix and PDF-417
- Available to set barcode width, resolution, orientation, image format and so on
- Offer royalty-free, flexible and perpetual license of Barcode Generator for RDLC Reports
Download KA.Barcode for RDLC Reports Term of Evaluation
Users are able to use KA.Barcode for RDLC Reports evaluation for ever without charge. Limitation of Evaluation
Randomly, a "KA Barcode" watermark will appear on generated barcode images. So, users can only apply them to non-commercial applications. Only linear and 2D barcode images created with our suitable license are permitted to be used in business applications. How to Create Barcodes in RDLC Reports for Web Forms
- Create an ASP.NET web form project in Visual Studio and add "KeepAutomation.Barcode.RDLC.dll" to reference.
- In "Solution Explorer", right click your project to add a new "Class" item named "BarcodeDemo".
- Copy the sample code into your created "Class" item. Go to "Build" tab and choose "Build Web Site".
- Switch to "Solution Explorer" and right click your web project to add a new "Report" item.
- Drag a "Table" in "Report Items" under "Toolbox" to the report and go to "Website Data Sources" tab, insert "BarcodeName" and "BarcodeId".
- Now, switch back to "Toolbox", insert "Image" item to the last column and name the column "Barcode".
- Respectively revise "Source" to "Database", "MIMEType" to "image/jpeg", "Value" to "=Fields!Byte.Value" in "Properties" window.
- In "Solution Explorer", right click "Default.aspx" and select "View Designer" to add a "ReportViewer" to the project.
- Choose your created report and run your ASP.NET web project. (Choose "Modify the Web.config file to enable debugging" in the pop-up window and click "OK").
C# Sample code
public class BarocdeDemo {
private string m_barcodeName; private int m_barcodeId; private byte[] m_byte; public BarocdeDemo(string barcodeName, int barcodeId, string data) { m_barcodeName = barcodeName; m_barcodeId = barcodeId; BarCode barcode = new BarCode(); barcode.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto; barcode.CodeToEncode = data; m_byte = barcode.generateBarcodeToByteArray(); } public byte[] Byte { get { return m_byte; } } public string BarcodeName { get { return m_barcodeName; } } public int BarcodeId { get { return m_barcodeId; } } } public class Merchant { private List<BarocdeDemo> m_barcodes; public Merchant() { m_barcodes = new List<BarocdeDemo>(); m_barcodes.Add(new BarocdeDemo("code11", 001, "code11")); m_barcodes.Add(new BarocdeDemo("code25", 002, "code25")); m_barcodes.Add(new BarocdeDemo("code39", 003, "code39")); m_barcodes.Add(new BarocdeDemo("code93", 004, "code93")); m_barcodes.Add(new BarocdeDemo("code128",005, "code128")); m_barcodes.Add(new BarocdeDemo("upcean", 006, "upcean")); } public List<BarocdeDemo> GetProducts() { return m_barcodes; } } VB Sample code
Public Class BarocdeDemo
Private m_barcodeName As String Private m_barcodeId As Integer Private m_byte As Byte() Public Sub New(barcodeName As String, barcodeId As Integer, data As String) m_barcodeName = barcodeName m_barcodeId = barcodeId Dim barcode As New BarCode() barcode.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto barcode.CodeToEncode = data m_byte = barcode.generateBarcodeToByteArray() End Sub Public ReadOnly Property [Byte]() As Byte() Get Return m_byte End Get End Property Public ReadOnly Property BarcodeName() As String Get Return m_barcodeName End Get End Property Public ReadOnly Property BarcodeId() As Integer Get Return m_barcodeId End Get End Property End Class Public Class Merchant Private m_barcodes As List(Of BarocdeDemo) Public Sub New() m_barcodes = New List(Of BarocdeDemo)() m_barcodes.Add(New BarocdeDemo("code11", 1, "code11")) m_barcodes.Add(New BarocdeDemo("code25", 2, "code25")) m_barcodes.Add(New BarocdeDemo("code39", 3, "code39")) m_barcodes.Add(New BarocdeDemo("code93", 4, "code93")) m_barcodes.Add(New BarocdeDemo("code128", 5, "code128")) m_barcodes.Add(New BarocdeDemo("upcean", 6, "upcean")) End Sub Public Function GetProducts() As List(Of BarocdeDemo) Return m_barcodes End Function End Class How to Create Barcodes in RDLC Reports for WinForms
- Create a new Windows Forms application in Visual Studio and then create a "DataSet" with the name "AdventureWorks.xsd".
- Move to the "Toolbox", select "Pointer", and drag "TableAdapter" to the new "DataSet".
- Define the connection to SQL Server AdventureWorks Sample Database.
- Insert the following string as SQL Statement: "SELECT ProductID, Name FROM Production.vProductAndDescription WHERE (CultureID = N'en') ".
- Right-click "vProductAndDescription" on the dataset to add a column (name it as "Barcode"), and change the data type to "System.Byte[]" in "Properties" window.
- Switch to "Solution Explorer" and add a new "Report" item.
- Insert a table to the new "Report" item and add three columns in the dataset to the report table details section.
- Drag and drop "Image" item to the last column, named as "Barcode".
- Switch to "Properties" window and change "Source", "MIMEType", "Value" to "Database", "image/jpeg", "=Fields!Barcode.Value" respectively.
- Then select "Form1.cs[Design]" and drag "ReportViewer" to Form1.
- Bind the data collection (Click "Report1.rdlc[Design]", then click "Report" and choose "Data Sources....").
- Add "KeepAutomation.Barcode.RDLC.dll" to project reference.
- Right click "Form1.cs" and select "View Code", then copy the sample code into the method Form1_Load.
- Use "KeepAutomation.Barcode.RDLC" namespace and run your Windows Forms project.
C# Sample code
private void Form1_Load(object sender, EventArgs e) { // load data to the data table this.vProductAndDescriptionTableAdapter.Fill this.vProductAndDescriptionTableAdapter.Fill(this.AdventureWorks.vProductAndDescription); // create a linear barcode object BarCode barcode = new BarCode(); // set barcode type barcode.Symbology = KeepAutomation.Barcode.Symbology.Code39; // draw barcodes for each data row foreach (AdventureWorks.vProductAndDescriptionRow row in this.AdventureWorks.vProductAndDescription.Rows) {// set barcode encoding data value barcode.CodeToEncode = row.ProductID.ToString(); // set drawing barcode image format barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
row.Barcode = barcode.generateBarcodeToByteArray(); } this.reportViewer1.RefreshReport(); } VB Sample code
Private Sub Form1_Load(sender As Object, e As EventArgs) ' load data to the data table this.vProductAndDescriptionTableAdapter.Fill Me.vProductAndDescriptionTableAdapter.Fill(Me.AdventureWorks.vProductAndDescription) ' create a linear barcode object Dim barcode As New BarCode() ' set barcode type barcode.Symbology = KeepAutomation.Barcode.Symbology.Code39 ' draw barcodes for each data row For Each row As AdventureWorks.vProductAndDescriptionRow In Me.AdventureWorks.vProductAndDescription.Rows ' set barcode encoding data value barcode.CodeToEncode = row.ProductID.ToString() ' set drawing barcode image format barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
row.Barcode = barcode.generateBarcodeToByteArray() Next Me.reportViewer1.RefreshReport() End Sub |
Download Free TrialIn Web RDLC ReportsIn Windows RDLCHow To Start Using C#Using VB.NETUsing ASP.NETUsing .NET WinformsData Matrix for RDLCPDF417 for RDLCQR Code for RDLCmoreCodabar for RDLCCode 39 for RDLCCode 128 for RDLCEAN-8 for RDLCEAN-13 for RDLCEAN 128 for RDLCIntelligent Mail for RDLCInterleaved 2 of 5 for RDLCISBN for RDLCITF-14 for RDLCRM4SCC for RDLCUPC-A for RDLCUPC-E for RDLCmore
|