Code 39 Extended

  • 3 min to read

Short Description

It is possible, using the Code 39's "Full ASCII Mode" to encode all 128 ASCII characters. This is accomplished by using the ($), (/), (%), and (+) symbols as "shift" characters. These characters combined with the single character that follows indicate which Full ASCII character is to be used.

Barcode - Code 39 Extended

Bar Code Properties

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

The following properties are specific to the Code 39 Extended type.

Important Note

The Code 39 Extended bar code, as opposed to Code 39, automatically replaces all necessary characters with special symbols, when required. This means that you do not need to do this manually, otherwise, the result will be incorrect.

For example, if you want to insert a "TAB" character into a bar code's text, use "\t", which will be replaced by "$I" for coding, and then into "TAB" after scanning:

Property Value
XRBarCode.Text: "12345\t678"
Coded text: "12345$I678"
Scanned text: "12345[TAB]678"

The checksum is not considered to be part of a bar code's text and checksum characters are never replaced. When the XRBarCode.ShowText and BarCodeGeneratorBase.CalcCheckSum properties are enabled, the bar code will not display a checksum character. This is required to avoid mistakenly treating a checksum as part of bar code text.

Examples

The following code creates a Code 39 Extended 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 CreateCode39ExBarCode(string BarCodeText) {
    // Create a bar code control.
    XRBarCode barCode = new XRBarCode();

    // Set the bar code's type to Code 39 Extended.
    barCode.Symbology = new Code39ExtendedGenerator();

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

    // Adjust the properties specific to the bar code type.
    ((Code39ExtendedGenerator)barCode.Symbology).CalcCheckSum = false;
    ((Code39ExtendedGenerator)barCode.Symbology).WideNarrowRatio = 2.5F;

    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(CreateCode39ExBarCode("012345678"));
}