|
|
|
|
|
|
|
How to create and print Avery address labels with USPS OneCode 4-State
Customer Barcode (4-CB) in Crystal Reports for .NET Windows Forms
Technologies used
-
Neodynamic Barcode Professional 3.0 (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 USPS OneCode 4-State Customer Barcode (4-CB) 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.
USPS OneCode 4-State Customer Barcode (4-CB)
USPS OneCode 4-State Customer Barcode (4-CB) is the next generation in the
evolution of USPS barcode technology. The OneCode Barcode Data Fields is
divided in two main fields, the Tracking Code and the Routing Code.
The 20-digit tracking code consists of the barcode identifier (2
digits), special services (3 digits), customer identifier (6
digits), and sequence number (9 digits) fields, while the routing code
consists of the delivery point ZIP Code which can be 0, 5, 9 or 11 digits long.
In this sample demo we will use a fictitious Tracking Code, for
instance, 00123123456123456789. For a real world usage of this sample,
you should contact USPS Customer Service in order they can assist you on
getting on a valid Tracking Code for your specific case.
The Routing Code will be specified by using the ZIP Code stored in the
XML file that we are going to use as our report's data source.
Please follow these steps:
-
Open Microsoft Visual Studio .NET
and create a new Windows Application
-
IMPORTE NOTE:
This Guide uses an XML Schema (XSD files) as data source for the report. Please note that this XML Schema will only be used to design the report in the Crystal Reports Designer.
You can easily generate an XML Schema using an ADO.NET DataSet object. This object has the WriteXmlSchema() method that creates an XML Schema file for you.
So, if you need to create a report for a Table in a SQL Server Database, you can create a DataSet object for that Table and then call the WriteXmlSchema() method to get the XML Schema file associated to it.
However, in this sample demo we're going to use an XML file instead of a SQL Server Database for simplicity only.
REMEMBER that this is required to DESIGN the reports. Once created the report you won't need it at RUNTIME when you deploy your application.
For sample demos using Typed DataSet or SQL Stored Procedures as Data Sources please refer to the following Guides instead:
-
Add to the project the XML file called AdventureWorksEmployees.xml
(you'll find it at the end of this guide ready for downloading)
-
With this file opened, go to the XML menu and click on Create Schema.
VS.NET will create an XML Schema file called AdventureWorksEmployees.xsd.
You'll find it in the Solution Explorer.
Remember that this file only will be use to design
the report.
-
Once we have the XML Schema file, we'll need to modify it and add a NEW element
that will represent our barcode images. To do this, double-click on the AdventureWorksEmployees.xsd
and add a new element whose name will be BarcodeImage and whose type
will be base64Binary as is shown in the following figure:
After that, save the XML Schema file!
-
Now it's time to create our CR report.
-
Open your Windows Forms at design time and drag & drop a CrystalReportViewer
control onto it. Set its Dock property to Fill and the DiplayGroupTree
to False.
-
Open the Solution Explorer window and add a reference to the Neodynamic.WinControls.BarcodeProfessional.dll
assembly. We're going to use Barcode Professional as a component
library.
-
In the code-behind class of the Form, add the following
namespace reference:
-
Finally, write the following code in the Form1_Load event
procedure:
-
That's it. Build the Windows Application and run it.
If you export the report to PDF format, then the USPS OneCode
barcodes are maintained!
Sample Files Download
If you need more information or assistance, please contact our
.
|
|
|
|
|
|
|