|
|
|
|
How to create Avery Address Labels in WPF with C# or VB.NET featuring USPS Postnet Barcodes
Technologies used
- Neodynamic Barcode Professional for WPF (any version)
- Microsoft .NET Framework 3.0 or greater
- Microsoft Visual Studio 2008
- Microsoft Visual Basic 2008 Express Edition
- Microsoft Visual C# 2008 Express Edition
|
 |

This demo - which source code files can be found at the end of this page available for downloading - demonstrates how you can easily create Avery Address Labels featuring USPS Postnet barcode in WPF Applications. Barcode Professional for WPF provides vector-based barcode generation producing high quality barcodes.
This step-by-step guide illustrates how you can create Avery Address Labels featuring Postnet barcodes by leveraging WPF Document and Printing capabilities together Barcode Professional for WPF.
The following figure is a screenshot of the demo application will be creating.
WPF Avery Address Labels featuring USPS Postnet Barcode
During the course of this walkthrough, you will accomplish the following activities:
- Create a WPF Application using Visual Studio 2008 or Express Editions.
- Create a WPF User Control which will represent an individual label featuring USPS Postnet barcode by leveraging Barcode Professional for WPF
- Create a .NET Class wrapping an Avery Address Label layout (In this case will be creating an "Ambassador Address Label � Avery 5160" and responsible of generating a FixedDocument object based on XML data source.
- Create a simple WPF Window which will display the Avery Address Label through out a WPF DocumentViewer control.
Please follow these steps:
- Ensure you have installed Barcode Professional for WPF
- Launch Visual Studio and create a new WPF Application
- Create a new folder in your project and name it "data" (without quotes)
- Add the AdventureWorksEmployees.xml file inside Data folder. That XML file contains info about AdventureWorks employees including Name, Address, City, State and Postal Code
- In this sample will be creating an "Ambassador Address Label � Avery 5160". This particular Avery Product features individual labels which size is 2.625 inch x 1 inch. We�ll create a WPF User Control which will represent each individual label and will hold a BarcodeProfessional WPF Control for encoding/generating USPS Postnet barcodes.
- Add a new WPF User Control to the project and name it AveryBarcodeLabel
- Resize the User Control to Width = 252 and Height = 96. The size value is calculated by translating the label size to WPF Device Independent Unit (DIU = 1/96th inch per unit). Based on our sample:
Width = 2.625 * 96 = 252
Height = 1 * 96 = 96
- After that, drag & drop from VS Toolbox to the User Control:
- 3 TextBlock
- 1 BarcodeProfessional
- The User Control elements layout should look like follows (bellow to the figure is the XAML code for reference)
- Now in the User Control code-behind class, change it so it looks like follows:
Visual Basic .NET
Visual C# .NET
- The "Ambassador Address Label - Avery 5160" features 30 labels per sheet and the sheet size as well as labels layout is the following:
We'll create a class for wrapping this info and the same will be the responsible of generating a FixedDocument object displaying all labels from data source.
- Add a new Class item and name it Avery5160
- After that, paste the following code for Avery5160 class:
Visual Basic .NET
Visual C# .NET
- The last step is for designing the Window element for displaying the Avery Labels in a DocumentViewer control. Open default Window1 file at design time and drag & drop a TextBlock and a DocumentViewer control. The Window elements layout should look like follows (bellow to the figure is the XAML code for reference)
Employees Avery Mail Address Labels With Postnet Barcode
Finally, in the Window code-behind class:
- Add the following methods:
Visual Basic .NET
Visual C# .NET
- Add the following code in the Window_Loaded event procedure:
Visual Basic .NET
Visual C# .NET
- That's it. Run your project. You should get something like the following:
WPF Avery Address Labels featuring USPS Postnet Barcode
Barcode Professional for WPF generates high quality vector-based barcodes
Sample Files Download
Here are the VB.NET and C# versions of this sample. Please
download the zip file and extract it.
Remember to download and install Barcode Professional for WPF in order to
reproduce this sample demo.
If you need more information or assistance, please contact our
.
|
|
|
|