PostNet

  • 2 min to read

Short Description

PostNet was developed by the United States Postal Service (USPS) to allow faster mail sorting and routing. PostNet codes are the familiar and unusual looking bar codes often printed on envelopes and business return mail.

Unlike most other bar codes, in which data is encoded in the width of the bars and spaces, PostNet actually encodes data in the height of the bars. That's why all the bars are of the same width, but not the same height.

Barcode - PostNet

Bar Code Properties

The type of a bar code control's Symbology property is PostNetGenerator.

The are no properties specific to the PostNet bar code type.

Examples

The following code creates a PostNet bar code and specifies its main properties.

using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreatePostNetBarCode(string BarCodeText) {
    // Create a bar code control.
    XRBarCode barCode = new XRBarCode();

    // Set the bar code's type to PostNet.
    barCode.Symbology = new PostNetGenerator();

    // Adjust the bar code's main properties.
    barCode.Text = BarCodeText;
    barCode.Width = 400;
    barCode.Height = 100;

    return barCode;
}

To add the XRBarCode to a report band, handle the report's XRControl.BeforePrint event.

using System.Drawing.Printing;
// ...

private void XtraReport1_BeforePrint(object sender, PrintEventArgs e) {
    this.Detail.Controls.Add(CreatePostNetBarCode("012345678"));
}