Neodynamic Barcode Professional 2.5 (or greater) for Windows Forms (WinControl)
Crystal Reports for .NET (any version)
Microsoft .NET Framework (any version)
Microsoft Visual Studio .NET (any version)
In the following Step-By-Step Guide we're going to create a Windows Application which includes a CR report for Avery address labels including Postnet barcode images generated by Barcode Professional.
For simplicity, we're going to use an XML file as the Data Source for our CR report. This XML file, available for downloading at the end of this guide, includes information of employees generated from Microsoft's AdventureWorks database sample.
Note: This guide was made using Visual Studio 2005 but you can use any other version of it needing in some cases minor changes.
Follow these steps:
Avery Labels Type | Labels Size | Labels per Sheet |
Return Address (Avery 5267) | 1/2" x 1-3/4" | 80 |
Address (Avery 5160) | 1" x 2-5/8" | 30 |
Address (Avery 5260) | 1" X 2-5/8" | 30 |
Address (Avery 5161) | 1" X 4" | 20 |
Address (Avery 5261) | 1" X 4" | 20 |
Address (Avery 5162) | 1-1/3" X 4" | 14 |
Address (Avery 5262) | 1-1/3" X 4" | 14 |
Address/Shipping (Avery 5163) | 2" X 4" | 10 |
Address/Shipping (Avery 5164) | 3-1/3" X 4" | 6 |
Clear Address (Avery 5660) | 1" X 2-3/4" | 30 |
Clear Address (Avery 5662) | 1-1/3" X 4-1/8" | 14 |
Clear Address (Avery 5663) | 2" X 4-1/8" | 10 |
Full Sheet (Avery 5165) | 8-1/2" X 11" | 1 |
File Folder (Avery 5266) | 2/3" X 3-7/16" | 30 |
3-1/2 Diskette (Avery 5196) | 2-3/4" X 2-3/4" | 9 |
3-1/2 Diskette - Red (Avery 5096) | ||
3-1/2 Diskette - Blue (Avery 5896) | ||
5-1/4 Diskette (Avery 5197) | 12 | |
5-1/4 Diskette - Red (Avery 5097) | ||
5-1/4 Diskette - Blue (Avery 5897) | ||
Audio Cassette (Avery 5198) | 1-5/8" X 3-1/2" | 12 |
Video Cassette Face (Avery 5199) | ||
Video Cassette Spine | ||
Name Badge - Red (Avery 5095) | 2-1/3" X 3-3/8" | 8 |
Name Badge (Avery 5395) | 2-1/3" X 3-3/8" | 8 |
Name Badge - Blue (Avery 5895) | 2-1/3" X 3-3/8" | 8 |
Name Tag (Avery 5383) | ||
Name Tag - Blue (Avery 5883) | ||
Name Tag (Avery 5384) | 3" X 4" | 6 |
Rotary Index Card (Avery 5385) | 2-1/6" X 4" | 8 |
Rotary Index Card (Avery 5386) | 3" X 5" | 4 |
Index Card (Avery 5388) | ||
Index/Post Card (Avery 5389) | 4" X 6" | 2 |
Round (Avery 5294) | 2-1/2" Diameter 12 |
Imports Neodynamic.WinControls.BarcodeProfessional
using Neodynamic.WinControls.BarcodeProfessional;
'Create a DataSet from the XML file
'REMEMBER to copy the XML file in the same location of the EXE Program
Dim xmlFile As String = System.IO.Directory.GetCurrentDirectory() & "\AdventureWorksEmployees.xml"
Dim ds As New DataSet
ds.ReadXml(xmlFile)
'The XML File with the data DOES NOT include
'the BarcodeImage "column" or element we've included
'in the XML Schema file.
'So, create the BarcodeImage column
'WARNING: you must name it as you did in the XML Schema
Dim dc As DataColumn = New DataColumn("BarcodeImage", GetType(Byte()))
'Add the BarcodeImage column to the DataTable
ds.Tables(0).Columns.Add(dc)
'Create a BarcodeProfessional object to fill
'the BarcodeImage column
Dim bc As BarcodeProfessional = New BarcodeProfessional
bc.Symbology = Symbology.Postnet
bc.PostnetHeightShortBar = 0.06F 'Set 5 if you use Barcode Professional 2.5
bc.PostnetHeightTallBar = 0.135F 'Set 12 if you use Barcode Professional 2.5
bc.QuietZoneWidth = 0
bc.AddChecksum = False
bc.DisplayCode = False
bc.BarWidth = 0.02F 'Set 2 if you use Barcode Professional 2.5
bc.BarRatio = 1
bc.Text = ""
'Now, generate and fill barcode images
For Each dr As DataRow In ds.Tables(0).Rows
'We're going to encode the PostalCode column
bc.Code = CType(dr("PostalCode"), String)
dr("BarcodeImage") = bc.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png)
Next
'Create an AveryMailLabels report object
'and set its data source with the DataSet
Dim report As AveryMailLabels = New AveryMailLabels
report.SetDataSource(ds)
'Show it!
CrystalReportViewer1.ReportSource = report
//Create a DataSet from the XML file
//REMEMBER to copy the XML file in the same location of the EXE Program
string xmlFile = System.IO.Directory.GetCurrentDirectory() + "\\AdventureWorksEmployees.xml";
DataSet ds = new DataSet();
ds.ReadXml(xmlFile);
//The XML File with the data DOES NOT include
//the BarcodeImage "column" or element we've included
//in the XML Schema file.
//So, create the BarcodeImage column
//WARNING: you must name it as you did in the XML Schema
DataColumn dc = new DataColumn("BarcodeImage", typeof(byte[]));
//Add the BarcodeImage column to the DataTable
ds.Tables[0].Columns.Add(dc);
//Create a BarcodeProfessional object to fill
//the BarcodeImage column
BarcodeProfessional bc = new BarcodeProfessional();
bc.Symbology = Symbology.Postnet;
bc.PostnetHeightShortBar = 0.06f; //Set 5 if you use Barcode Professional 2.5
bc.PostnetHeightTallBar = 0.135f; //Set 12 if you use Barcode Professional 2.5
bc.QuietZoneWidth = 0;
bc.AddChecksum = false;
bc.DisplayCode = false;
bc.BarWidth = 0.02f; //Set 2 if you use Barcode Professional 2.5
bc.BarRatio = 1;
bc.Text = "";
//Now, generate and fill barcode images
foreach (DataRow dr in ds.Tables[0].Rows)
{
//We're going to encode the PostalCode column
bc.Code = (string)dr["PostalCode"];
dr["BarcodeImage"] = bc.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png);
}
//Create a AveryMailLabels report object
//and set its data source with the DataSet
AveryMailLabels report = new AveryMailLabels();
report.SetDataSource(ds);
//Show it!
crystalReportViewer1.ReportSource = report;
Sample Files Download
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.